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

Unified Diff: lib/elemHide.js

Issue 29773570: Issue 6652 - Implement fast selector lookups for unknown domains (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Inline doesFilterApply Created May 15, 2018, 3:37 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 | « no previous file | no next file » | 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
@@ -113,30 +113,16 @@
let filters = filtersByDomain.get(domain);
if (!filters)
filtersByDomain.set(domain, filters = new Map());
filters.set(filter, isIncluded);
}
}
}
-
-/**
- * Checks whether a filter applies on a domain
- * @param {Filter} filter
- * @param {string} [domain]
- * @param {Set.<Filter>} excludeSet
- * @returns {boolean}
- */
-function doesFilterApply(filter, domain, excludeSet)
-{
- return (excludeSet.size == 0 || !excludeSet.has(filter)) &&
- !exports.ElemHide.getException(filter, domain);
-}
-
/**
* Returns a list of domain-specific filters matching a domain
* @param {string} [domain]
* @returns {Array.<{domain: string, filters: ?Map.<Filter,boolean>}>}
*/
function getSpecificFiltersForDomain(domain)
{
let filtersList = [];
@@ -174,19 +160,24 @@
for (let i = 0; i < filtersList.length; i++)
{
let {filters} = filtersList[i];
if (filters)
{
for (let [filter, isIncluded] of filters)
{
if (!isIncluded)
+ {
excludeSet.add(filter);
- else if (doesFilterApply(filter, domain, excludeSet))
+ }
+ else if ((excludeSet.size == 0 || !excludeSet.has(filter)) &&
+ !exports.ElemHide.getException(filter, domain))
+ {
matches.push(filter.selector);
+ }
}
}
}
return matches;
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld