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

Unified Diff: lib/whitelisting.js

Issue 29417597: Issue 5161 - Use maps and sets where appropriate (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Address comments to Patch Set 1 Created May 4, 2017, 2:44 p.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
Index: lib/whitelisting.js
===================================================================
--- a/lib/whitelisting.js
+++ b/lib/whitelisting.js
@@ -123,17 +123,17 @@
exports.getKey = (page, frame) =>
{
let keys = sitekeys.get(page);
if (!keys)
return null;
for (; frame != null; frame = frame.parent)
{
- let key = keys[stringifyURL(frame.url)];
+ let key = keys.get(stringifyURL(frame.url));
if (key)
return key;
}
return null;
};
function checkKey(token, url)
@@ -153,20 +153,20 @@
return key;
}
function recordKey(key, page, url)
{
let keys = sitekeys.get(page);
if (!keys)
{
- keys = Object.create(null);
+ keys = new Map();
sitekeys.set(page, keys);
}
- keys[stringifyURL(url)] = key;
+ keys.set(stringifyURL(url), key);
}
port.on("filters.addKey", (message, sender) =>
{
let key = checkKey(message.token, sender.frame.url);
if (key)
recordKey(key, sender.page, sender.frame.url);
});

Powered by Google App Engine
This is Rietveld