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

Unified Diff: lib/matcher.js

Issue 5636077285015552: Issue 656 - Replace some __proto__ with Object.create (Closed)
Patch Set: Created June 23, 2014, 8:46 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 | « lib/filterStorage.js ('k') | lib/subscriptionClasses.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/matcher.js
===================================================================
--- a/lib/matcher.js
+++ b/lib/matcher.js
@@ -44,18 +44,18 @@ Matcher.prototype = {
*/
keywordByFilter: null,
/**
* Removes all known filters
*/
clear: function()
{
- this.filterByKeyword = {__proto__: null};
- this.keywordByFilter = {__proto__: null};
+ this.filterByKeyword = Object.create(null);
+ this.keywordByFilter = Object.create(null);
},
/**
* Adds a filter to the matcher
* @param {RegExpFilter} filter
*/
add: function(filter)
{
@@ -210,18 +210,18 @@ Matcher.prototype = {
* Combines a matcher for blocking and exception rules, automatically sorts
* rules into two Matcher instances.
* @constructor
*/
function CombinedMatcher()
{
this.blacklist = new Matcher();
this.whitelist = new Matcher();
- this.keys = {__proto__: null};
- this.resultCache = {__proto__: null};
+ this.keys = Object.create(null);
+ this.resultCache = Object.create(null);
}
exports.CombinedMatcher = CombinedMatcher;
/**
* Maximal number of matching cache entries to be kept
* @type Number
*/
CombinedMatcher.maxCacheEntries = 1000;
@@ -260,18 +260,18 @@ CombinedMatcher.prototype =
/**
* @see Matcher#clear
*/
clear: function()
{
this.blacklist.clear();
this.whitelist.clear();
- this.keys = {__proto__: null};
- this.resultCache = {__proto__: null};
+ this.keys = Object.create(null);
+ this.resultCache = Object.create(null);
this.cacheEntries = 0;
},
/**
* @see Matcher#add
*/
add: function(filter)
{
@@ -285,17 +285,17 @@ CombinedMatcher.prototype =
else
this.whitelist.add(filter);
}
else
this.blacklist.add(filter);
if (this.cacheEntries > 0)
{
- this.resultCache = {__proto__: null};
+ this.resultCache = Object.create(null);
this.cacheEntries = 0;
}
},
/**
* @see Matcher#remove
*/
remove: function(filter)
@@ -310,17 +310,17 @@ CombinedMatcher.prototype =
else
this.whitelist.remove(filter);
}
else
this.blacklist.remove(filter);
if (this.cacheEntries > 0)
{
- this.resultCache = {__proto__: null};
+ this.resultCache = Object.create(null);
this.cacheEntries = 0;
}
},
/**
* @see Matcher#findKeyword
*/
findKeyword: function(filter)
@@ -401,17 +401,17 @@ CombinedMatcher.prototype =
let key = location + " " + contentType + " " + docDomain + " " + thirdParty;
if (key in this.resultCache)
return this.resultCache[key];
let result = this.matchesAnyInternal(location, contentType, docDomain, thirdParty);
if (this.cacheEntries >= CombinedMatcher.maxCacheEntries)
{
- this.resultCache = {__proto__: null};
+ this.resultCache = Object.create(null);
this.cacheEntries = 0;
}
this.resultCache[key] = result;
this.cacheEntries++;
return result;
},
« no previous file with comments | « lib/filterStorage.js ('k') | lib/subscriptionClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld