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: Created Feb. 5, 2019, 3:19 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,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}
« 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