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: address comments Created Sept. 20, 2017, 11:31 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') | no next file with comments »
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..417e4d8df3cc13fdd4daa0d6ac14489ad73b92cb 100644
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -79,9 +79,9 @@ Filter.prototype =
/**
* Cache for known filters, maps string representation to filter objects.
- * @type {Object}
+ * @type {Map.<string,Filter>}
*/
-Filter.knownFilters = Object.create(null);
+Filter.knownFilters = new Map();
/**
* Regular expression that element hiding filters should match
@@ -108,10 +108,10 @@ Filter.optionsRegExp = /\$(~?[\w-]+(?:=[^,\s]+)?(?:,~?[\w-]+(?:=[^,\s]+)?)*)$/;
*/
Filter.fromText = function(text)
{
- if (text in Filter.knownFilters)
- return Filter.knownFilters[text];
+ let ret = Filter.knownFilters.get(text);
+ if (ret)
kzar 2017/09/20 12:30:24 Just an observation since I don't think it matters
+ return ret;
- let ret;
let match = (text.includes("#") ? Filter.elemhideRegExp.exec(text) : null);
if (match)
{
@@ -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') | no next file with comments »

Powered by Google App Engine
This is Rietveld