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: Remove blank line Created May 17, 2017, 9:47 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
« no previous file with comments | « lib/popupBlocker.js ('k') | options.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
});
« no previous file with comments | « lib/popupBlocker.js ('k') | options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld