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

Unified Diff: lib/elemHide.js

Issue 29551632: Issue 5735 - Use JS Map instead of Object for global filtersByDomain in elemHide.js (Closed) Base URL: https://github.com/adblockplus/adblockpluscore.git
Patch Set: Created Sept. 21, 2017, 11:42 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 | no next file » | 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 a6d2c5a7a27c05e91a0186320b560f3db405e721..fc2226343341a5a9859c108faaa51309f2efe483 100644
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -39,9 +39,9 @@ let keyByFilter = Object.create(null);
/**
* Nested lookup table, filter (or false if inactive) by filter key by domain.
* (Only contains filters that aren't unconditionally matched for all domains.)
- * @type {Object}
+ * @type {Map.<string,Object>}
*/
-let filtersByDomain = Object.create(null);
+let filtersByDomain = new Map();
/**
* Lookup table, filter key by selector. (Only used for selectors that are
@@ -92,7 +92,7 @@ let ElemHide = exports.ElemHide = {
{
filterByKey = [];
keyByFilter = Object.create(null);
- filtersByDomain = Object.create(null);
+ filtersByDomain = new Map();
filterKeyBySelector = Object.create(null);
unconditionalSelectors = unconditionalFilterKeys = null;
knownExceptions = Object.create(null);
@@ -105,9 +105,9 @@ let ElemHide = exports.ElemHide = {
let domains = filter.domains || defaultDomains;
for (let [domain, isIncluded] of domains)
{
- let filters = filtersByDomain[domain];
+ let filters = filtersByDomain.get(domain);
if (!filters)
- filters = filtersByDomain[domain] = Object.create(null);
+ filtersByDomain.set(domain, filters = Object.create(null));
sergei 2017/09/21 12:00:26 filters are changed in https://codereview.adblockp
if (isIncluded)
filters[key] = filter;
@@ -183,7 +183,7 @@ let ElemHide = exports.ElemHide = {
let domains = filter.domains || defaultDomains;
for (let domain of domains.keys())
{
- let filters = filtersByDomain[domain];
+ let filters = filtersByDomain.get(domain);
if (filters)
delete filters[key];
}
@@ -362,7 +362,7 @@ let ElemHide = exports.ElemHide = {
if (specificOnly && currentDomain == "")
break;
- let filters = filtersByDomain[currentDomain];
+ let filters = filtersByDomain.get(currentDomain);
if (filters)
{
for (let filterKey in filters)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld