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

Unified Diff: lib/elemHide.js

Issue 29791555: Issue 6727 - Use string rather than map for single-domain filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created May 26, 2018, 10:52 a.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 | lib/filterClasses.js » ('j') | lib/filterClasses.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHide.js
===================================================================
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -67,16 +67,20 @@
/**
* Adds a filter to the lookup table of filters by domain.
* @param {Filter} filter
*/
function addToFiltersByDomain(filter)
{
let domains = filter.domains || defaultDomains;
+
+ if (typeof domains == "string")
sergei 2018/05/28 09:22:07 Will the refactoring of that `typeof DOMAINS == "s
kzar 2018/06/05 16:51:30 Agreed, if possible (without messing up performanc
+ domains = [[domains, true]];
+
for (let [domain, isIncluded] of domains)
{
// There's no need to note that a filter is generically disabled.
if (!isIncluded && domain == "")
continue;
let filters = filtersByDomain.get(domain);
if (!filters)
@@ -183,17 +187,21 @@
{
filterBySelector.delete(filter.selector);
unconditionalSelectors = null;
}
// Conditionally applied element hiding filters
else
{
let domains = filter.domains || defaultDomains;
- for (let domain of domains.keys())
+
+ if (typeof domains == "string")
+ domains = [[domains]];
+
+ for (let [domain] of domains)
{
let filters = filtersByDomain.get(domain);
if (filters)
filters.delete(filter);
}
}
knownFilters.delete(filter);
« no previous file with comments | « no previous file | lib/filterClasses.js » ('j') | lib/filterClasses.js » ('J')

Powered by Google App Engine
This is Rietveld