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,21 @@ |
* |
* @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)) |
hub
2019/02/06 12:55:05
I assume that this change doesn't cause a performa
Manish Jethani
2019/02/06 13:13:31
This is no longer a hot spot and in fact this comm
Manish Jethani
2019/02/06 13:17:06
Done.
|
{ |
- if (specificOnly && currentDomain == "") |
- break; |
- |
let filters = filtersByDomain.get(currentDomain); |
if (filters) |
{ |
for (let [filter, isIncluded] of filters) |
{ |
if (!isIncluded) |
{ |
excluded.add(filter); |
@@ -193,22 +190,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} |