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

Unified Diff: lib/common.js

Issue 29780560: Issue 6665 - Optimize element hiding emulation filter lookups (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Use String.indexOf for subdomains Created May 14, 2018, 2:22 a.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 | lib/elemHideEmulation.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/common.js
===================================================================
--- a/lib/common.js
+++ b/lib/common.js
@@ -96,8 +96,27 @@
}
}
selectors.push(selector.substring(start));
return selectors;
}
exports.splitSelector = splitSelector;
+
+/**
+ * Yields subdomains of a domain
+ * @param {string} domain
+ * @yields {string}
+ */
+function* subdomains(domain)
+{
+ while (true)
+ {
+ let index = domain.indexOf(".");
+ if (index == -1)
+ break;
+
+ yield domain = domain.substring(index + 1);
+ }
+}
+
+exports.subdomains = subdomains;
« no previous file with comments | « no previous file | lib/elemHideEmulation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld