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

Unified Diff: lib/elemHide.js

Issue 29757584: Issue 6562 - Remove the unused provideFilterKeys parameter (Closed)
Patch Set: Created April 20, 2018, 6:41 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') | test/elemHide.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHide.js
diff --git a/lib/elemHide.js b/lib/elemHide.js
index 597a5357844a6a27de6afeaa7eb2e3260288341f..1f6429fda35be0e4060bd1e92e2b236388bcc4d2 100644
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -57,13 +57,6 @@ let filterKeyBySelector = new Map();
*/
let unconditionalSelectors = null;
-/**
- * This array caches the values of filterKeyBySelector table (filterIds for
- * selectors which unconditionally apply on all domains). It will be null if the
- * cache needs to be rebuilt.
- */
-let unconditionalFilterKeys = null;
-
/**
* Object to be used instead when a filter has a blank domains property.
*/
@@ -97,7 +90,7 @@ let ElemHide = exports.ElemHide = {
collection.clear();
}
filterByKey = [];
- unconditionalSelectors = unconditionalFilterKeys = null;
+ unconditionalSelectors = null;
FilterNotifier.emit("elemhideupdate");
},
@@ -139,7 +132,7 @@ let ElemHide = exports.ElemHide = {
{
this._addToFiltersByDomain(filterKey, filterByKey[filterKey]);
filterKeyBySelector.delete(selector);
- unconditionalSelectors = unconditionalFilterKeys = null;
+ unconditionalSelectors = null;
}
knownExceptions.add(filter.text);
@@ -156,7 +149,7 @@ let ElemHide = exports.ElemHide = {
{
// The new filter's selector is unconditionally applied to all domains
filterKeyBySelector.set(filter.selector, key);
- unconditionalSelectors = unconditionalFilterKeys = null;
+ unconditionalSelectors = null;
}
else
{
@@ -173,7 +166,7 @@ let ElemHide = exports.ElemHide = {
if (filterKeyBySelector.get(filter.selector) == key)
{
filterKeyBySelector.delete(filter.selector);
- unconditionalSelectors = unconditionalFilterKeys = null;
+ unconditionalSelectors = null;
return;
}
@@ -288,24 +281,6 @@ let ElemHide = exports.ElemHide = {
return unconditionalSelectors.slice();
},
- /**
- * Returns a list of filter keys for selectors which apply to all websites
- * without exception.
- * @returns {number[]}
- */
- getUnconditionalFilterKeys()
- {
- if (!unconditionalFilterKeys)
- {
- let selectors = this.getUnconditionalSelectors();
- unconditionalFilterKeys = [];
- for (let selector of selectors)
- unconditionalFilterKeys.push(filterKeyBySelector.get(selector));
- }
- return unconditionalFilterKeys.slice();
- },
-
-
/**
* Constant used by getSelectorsForDomain to return all selectors applying to
* a particular hostname.
@@ -326,32 +301,22 @@ let ElemHide = exports.ElemHide = {
/**
* Determines from the current filter list which selectors should be applied
- * on a particular host name. Optionally returns the corresponding filter
- * keys.
+ * on a particular host name.
* @param {string} domain
* @param {number} [criteria]
* One of the following: ElemHide.ALL_MATCHING, ElemHide.NO_UNCONDITIONAL or
* ElemHide.SPECIFIC_ONLY.
- * @param {boolean} [provideFilterKeys]
- * If true, the function will return a list of corresponding filter keys in
- * addition to selectors.
- * @returns {string[]|Array.<string[]>}
- * List of selectors or an array with two elements (list of selectors and
- * list of corresponding keys) if provideFilterKeys is true.
+ * @returns {string[]}
+ * List of selectors.
*/
- getSelectorsForDomain(domain, criteria, provideFilterKeys)
+ getSelectorsForDomain(domain, criteria)
{
- let filterKeys = [];
let selectors = [];
if (typeof criteria == "undefined")
criteria = ElemHide.ALL_MATCHING;
if (criteria < ElemHide.NO_UNCONDITIONAL)
- {
selectors = this.getUnconditionalSelectors();
- if (provideFilterKeys)
- filterKeys = this.getUnconditionalFilterKeys();
- }
let specificOnly = (criteria >= ElemHide.SPECIFIC_ONLY);
let seenFilters = new Set();
@@ -371,11 +336,7 @@ let ElemHide = exports.ElemHide = {
seenFilters.add(filterKey);
if (filter && !this.getException(filter, domain))
- {
selectors.push(filter.selector);
- // It is faster to always push the key, even if not required.
- filterKeys.push(filterKey);
- }
}
}
@@ -386,8 +347,6 @@ let ElemHide = exports.ElemHide = {
currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
}
- if (provideFilterKeys)
- return [selectors, filterKeys];
return selectors;
}
};
« no previous file with comments | « no previous file | test/elemHide.js » ('j') | test/elemHide.js » ('J')

Powered by Google App Engine
This is Rietveld