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

Unified Diff: lib/elemHide.js

Issue 29550662: Issue 5735 - Use JS Map instead of Object for property domains of Filter objects (Closed) Base URL: https://github.com/adblockplus/adblockpluscore.git
Patch Set: address comments Created Sept. 21, 2017, 10:43 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') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHide.js
diff --git a/lib/elemHide.js b/lib/elemHide.js
index e9243853e3733c83632710b690e69224f1983bea..a6d2c5a7a27c05e91a0186320b560f3db405e721 100644
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -66,8 +66,7 @@ let unconditionalFilterKeys = null;
/**
* Object to be used instead when a filter has a blank domains property.
*/
-let defaultDomains = Object.create(null);
-defaultDomains[""] = true;
+let defaultDomains = new Map([["", true]]);
/**
* Lookup table, keys are known element hiding exceptions
@@ -104,13 +103,13 @@ let ElemHide = exports.ElemHide = {
_addToFiltersByDomain(key, filter)
{
let domains = filter.domains || defaultDomains;
- for (let domain in domains)
+ for (let [domain, isIncluded] of domains)
{
let filters = filtersByDomain[domain];
if (!filters)
filters = filtersByDomain[domain] = Object.create(null);
- if (domains[domain])
+ if (isIncluded)
filters[key] = filter;
else
filters[key] = false;
@@ -182,7 +181,7 @@ let ElemHide = exports.ElemHide = {
// We haven't found this filter in unconditional filters, look in
// filtersByDomain.
let domains = filter.domains || defaultDomains;
- for (let domain in domains)
+ for (let domain of domains.keys())
{
let filters = filtersByDomain[domain];
if (filters)
« no previous file with comments | « no previous file | lib/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld