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

Unified Diff: lib/elemHide.js

Issue 29551635: Issue 5735 - Use JS Map instead of Object for filters which are stored in filtersByDomain in elem... (Closed) Base URL: https://github.com/adblockplus/adblockpluscore.git
Patch Set: Created Sept. 21, 2017, 11:44 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 fc2226343341a5a9859c108faaa51309f2efe483..e99bb8a7f269e4df2370fb95bd950031503540b4 100644
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -39,7 +39,7 @@ 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 {Map.<string,Object>}
+ * @type {Map.<string,Map.<string,(Filter|boolean)>>}
*/
let filtersByDomain = new Map();
@@ -107,12 +107,8 @@ let ElemHide = exports.ElemHide = {
{
let filters = filtersByDomain.get(domain);
if (!filters)
- filtersByDomain.set(domain, filters = Object.create(null));
-
- if (isIncluded)
- filters[key] = filter;
- else
- filters[key] = false;
+ filtersByDomain.set(domain, filters = new Map());
+ filters.set(key, isIncluded ? filter : false);
}
},
@@ -185,7 +181,7 @@ let ElemHide = exports.ElemHide = {
{
let filters = filtersByDomain.get(domain);
if (filters)
- delete filters[key];
+ filters.delete(key);
}
},
@@ -365,13 +361,12 @@ let ElemHide = exports.ElemHide = {
let filters = filtersByDomain.get(currentDomain);
if (filters)
{
- for (let filterKey in filters)
+ for (let [filterKey, filter] of filters)
{
if (filterKey in seenFilters)
continue;
seenFilters[filterKey] = true;
- let filter = filters[filterKey];
if (filter && !this.getException(filter, domain))
{
selectors.push(filter.selector);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld