Index: lib/elemHide.js |
diff --git a/lib/elemHide.js b/lib/elemHide.js |
index e99bb8a7f269e4df2370fb95bd950031503540b4..81d584767bb94bb3423e43f4a02e85a159d9f488 100644 |
--- a/lib/elemHide.js |
+++ b/lib/elemHide.js |
@@ -32,9 +32,9 @@ let filterByKey = []; |
/** |
* Lookup table, keys of the filters by filter text |
- * @type {Object} |
+ * @type {Map.<string,string>} |
sergei
2017/09/21 12:02:10
Pay attention that after switching from Object to
kzar
2017/09/22 10:50:15
Yea, it looks like we only used the Filter's text
Wladimir Palant
2017/09/25 10:59:31
Agreed, we should use Filter objects as keys here.
sergei
2017/09/25 13:41:23
Done.
I have checked when the type of key here is
Wladimir Palant
2017/09/25 13:57:16
A change in memory usage would be unexpected, both
|
*/ |
-let keyByFilter = Object.create(null); |
+let keyByFilter = new Map(); |
/** |
* Nested lookup table, filter (or false if inactive) by filter key by domain. |
@@ -91,7 +91,7 @@ let ElemHide = exports.ElemHide = { |
clear() |
{ |
filterByKey = []; |
- keyByFilter = Object.create(null); |
+ keyByFilter = new Map(); |
filtersByDomain = new Map(); |
filterKeyBySelector = Object.create(null); |
unconditionalSelectors = unconditionalFilterKeys = null; |
@@ -143,11 +143,11 @@ let ElemHide = exports.ElemHide = { |
} |
else |
{ |
- if (filter.text in keyByFilter) |
+ if (keyByFilter.has(filter.text)) |
return; |
let key = filterByKey.push(filter) - 1; |
- keyByFilter[filter.text] = key; |
+ keyByFilter.set(filter.text, key); |
if (!(filter.domains || filter.selector in exceptions)) |
{ |
@@ -204,12 +204,12 @@ let ElemHide = exports.ElemHide = { |
} |
else |
{ |
- if (!(filter.text in keyByFilter)) |
+ let key = keyByFilter.get(filter.text); |
+ if (typeof key == "undefined") |
return; |
- let key = keyByFilter[filter.text]; |
delete filterByKey[key]; |
- delete keyByFilter[filter.text]; |
+ keyByFilter.delete(filter.text); |
this._removeFilterKey(key, filter); |
} |