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: Created Sept. 20, 2017, 12:59 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 | lib/filterClasses.js » ('j') | lib/filterClasses.js » ('J')
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..3b0a9402eafe19fe2cd07539fe57e98e356a09ec 100644
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -66,8 +66,8 @@ 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();
+defaultDomains.set("", true);
Wladimir Palant 2017/09/21 08:11:44 You can initialize the Map object immediately: new
sergei 2017/09/21 10:50:33 Done.
/**
* Lookup table, keys are known element hiding exceptions
@@ -104,13 +104,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);
Wladimir Palant 2017/09/21 08:11:44 Shouldn't this be turned in to a Map object as wel
sergei 2017/09/21 10:50:33 No, I find the change of filtersByDomain self-cont
- if (domains[domain])
+ if (isIncluded)
filters[key] = filter;
else
filters[key] = false;
@@ -182,7 +182,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') | lib/filterClasses.js » ('J')

Powered by Google App Engine
This is Rietveld