Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/elemHide.js

Issue 29999569: Noissue - Use suffixes function (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Remove misleading comment Created Feb. 6, 2019, 1:15 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/domain.js ('k') | lib/filterClasses.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHide.js
===================================================================
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -18,16 +18,17 @@
"use strict";
/**
* @fileOverview Element hiding implementation.
*/
const {ElemHideExceptions} = require("./elemHideExceptions");
const {filterNotifier} = require("./filterNotifier");
+const {suffixes} = require("./domain");
/**
* The maximum number of selectors in a CSS rule. This is used by
* <code>{@link createStyleSheet}</code> to split up a long list of selectors
* into multiple rules.
* @const {number}
* @default
*/
@@ -164,25 +165,19 @@
*
* @returns {Array.<string>} The list of selectors.
*/
function getConditionalSelectors(domain, specificOnly)
{
let selectors = [];
let excluded = new Set();
- let currentDomain = domain;
- // This code is a performance hot-spot, which is why we've made certain
- // micro-optimisations. Please be careful before making changes.
- while (true)
+ for (let currentDomain of suffixes(domain, !specificOnly))
{
- if (specificOnly && currentDomain == "")
- break;
-
let filters = filtersByDomain.get(currentDomain);
if (filters)
{
for (let [filter, isIncluded] of filters)
{
if (!isIncluded)
{
excluded.add(filter);
@@ -193,22 +188,16 @@
if ((excluded.size == 0 || !excluded.has(filter)) &&
!ElemHideExceptions.getException(selector, domain))
{
selectors.push(selector);
}
}
}
}
-
- if (currentDomain == "")
- break;
-
- let nextDot = currentDomain.indexOf(".");
- currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
}
return selectors;
}
/**
* Returns the default style sheet that applies on all domains.
* @returns {string}
« no previous file with comments | « lib/domain.js ('k') | lib/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld