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

Unified Diff: lib/elemHide.js

Issue 29909555: Issue 7046 - Defer caching of domain maps (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Do not cache value for generic filters Created Oct. 14, 2018, 12:26 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
@@ -106,21 +106,21 @@
}
return domain;
}
/**
* Adds a filter to the lookup table of filters by domain.
* @param {Filter} filter
+ * @param {?Map.<string,boolean>} [domains]
*/
-function addToFiltersByDomain(filter)
+function addToFiltersByDomain(filter, domains = filter.domains)
{
- let domains = filter.domains || defaultDomains;
- for (let [domain, isIncluded] of domains)
+ for (let [domain, isIncluded] of domains || defaultDomains)
{
// There's no need to note that a filter is generically disabled.
if (!isIncluded && domain == "")
continue;
let filters = filtersByDomain.get(domain);
if (!filters)
filtersByDomain.set(domain, filters = new Map());
@@ -280,29 +280,29 @@
*/
add(filter)
{
if (knownFilters.has(filter))
return;
commonStyleSheet = null;
- let {selector} = filter;
+ let {domains, selector} = filter;
- if (!(filter.domains || ElemHideExceptions.hasExceptions(selector)))
+ if (!(domains || ElemHideExceptions.hasExceptions(selector)))
{
// The new filter's selector is unconditionally applied to all domains
filterBySelector.set(selector, filter);
unconditionalSelectors = null;
defaultStyleSheet = null;
}
else
{
// The new filter's selector only applies to some domains
- addToFiltersByDomain(filter);
+ addToFiltersByDomain(filter, domains);
}
knownFilters.add(filter);
filterNotifier.emit("elemhideupdate");
},
/**
* Removes an element hiding 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