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

Unified Diff: lib/elemHide.js

Issue 29882558: Issue 6955 - Avoid making copies of common selector list (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Sept. 16, 2018, 4:07 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 | « no previous file | test/elemHide.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHide.js
===================================================================
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -81,17 +81,17 @@
/**
* Returns a list of selectors that apply on each website unconditionally.
* @returns {string[]}
*/
function getUnconditionalSelectors()
{
if (!unconditionalSelectors)
- unconditionalSelectors = [...filterBySelector.keys()];
+ unconditionalSelectors = Object.freeze([...filterBySelector.keys()]);
return unconditionalSelectors;
}
ElemHideExceptions.on("added", ({selector}) =>
{
// If this is the first exception for a previously unconditionally applied
// element hiding selector we need to take care to update the lookups.
@@ -231,13 +231,18 @@
if (currentDomain == "")
break;
let nextDot = currentDomain.indexOf(".");
currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
}
if (!specificOnly)
- selectors = getUnconditionalSelectors().concat(selectors);
+ {
+ // Avoid making a copy if there are no domain-specific selectors.
+ selectors = selectors.length > 0 ?
+ getUnconditionalSelectors().concat(selectors) :
+ getUnconditionalSelectors();
+ }
return selectors;
}
};
« no previous file with comments | « no previous file | test/elemHide.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld