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

Unified Diff: lib/elemHideEmulation.js

Issue 29743730: Issue 6559 - Use maps and sets where appropriate (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created April 5, 2018, 5:38 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
« lib/elemHide.js ('K') | « lib/elemHide.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHideEmulation.js
===================================================================
--- a/lib/elemHideEmulation.js
+++ b/lib/elemHideEmulation.js
@@ -19,61 +19,60 @@
/**
* @fileOverview Element hiding emulation implementation.
*/
const {ElemHide} = require("./elemHide");
const {Filter} = require("./filterClasses");
-let filters = Object.create(null);
+let filters = new Set();
/**
* Container for element hiding emulation filters
* @class
*/
let ElemHideEmulation = {
/**
* Removes all known filters
*/
clear()
{
- filters = Object.create(null);
+ filters.clear();
},
/**
* Add a new element hiding emulation filter
* @param {ElemHideEmulationFilter} filter
*/
add(filter)
{
- filters[filter.text] = true;
+ filters.add(filter.text);
},
/**
* Removes an element hiding emulation filter
* @param {ElemHideEmulationFilter} filter
*/
remove(filter)
{
- delete filters[filter.text];
+ filters.delete(filter.text);
},
/**
* Returns a list of all rules active on a particular domain
* @param {string} domain
* @return {ElemHideEmulationFilter[]}
*/
getRulesForDomain(domain)
{
let result = [];
- let keys = Object.getOwnPropertyNames(filters);
- for (let key of keys)
+ for (let text of filters.values())
{
- let filter = Filter.fromText(key);
+ let filter = Filter.fromText(text);
if (filter.isActiveOnDomain(domain) &&
!ElemHide.getException(filter, domain))
{
result.push(filter);
}
}
return result;
}
« lib/elemHide.js ('K') | « lib/elemHide.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld