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

Unified Diff: lib/filterClasses.js

Issue 29550598: Issue 5735 - Use JS Map instead of Object for Filter.knownFilters (Closed) Base URL: https://github.com/adblockplus/adblockpluscore.git
Patch Set: Created Sept. 20, 2017, 8:20 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/filterStorage.js » ('j') | lib/filterStorage.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterClasses.js
diff --git a/lib/filterClasses.js b/lib/filterClasses.js
index 626eabad9538553550f08df724b14fbd077cd08b..504cd4b84503152459684997f83c5298947758b1 100644
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -81,7 +81,7 @@ Filter.prototype =
* Cache for known filters, maps string representation to filter objects.
* @type {Object}
*/
-Filter.knownFilters = Object.create(null);
+Filter.knownFilters = new Map();
/**
* Regular expression that element hiding filters should match
@@ -108,8 +108,8 @@ Filter.optionsRegExp = /\$(~?[\w-]+(?:=[^,\s]+)?(?:,~?[\w-]+(?:=[^,\s]+)?)*)$/;
*/
Filter.fromText = function(text)
{
- if (text in Filter.knownFilters)
- return Filter.knownFilters[text];
+ if (Filter.knownFilters.has(text))
+ return Filter.knownFilters.get(text);
Wladimir Palant 2017/09/20 08:59:10 It makes little sense to have two calls here. You
sergei 2017/09/20 09:22:40 I also thought about it because there are no `unde
let ret;
let match = (text.includes("#") ? Filter.elemhideRegExp.exec(text) : null);
@@ -136,7 +136,7 @@ Filter.fromText = function(text)
else
ret = RegExpFilter.fromText(text);
- Filter.knownFilters[ret.text] = ret;
+ Filter.knownFilters.set(ret.text, ret);
return ret;
};
« no previous file with comments | « no previous file | lib/filterStorage.js » ('j') | lib/filterStorage.js » ('J')

Powered by Google App Engine
This is Rietveld