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

Unified Diff: lib/coreUtils.js

Issue 29780560: Issue 6665 - Optimize element hiding emulation filter lookups (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Separate out subdomains generator function Created May 13, 2018, 7: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 | lib/elemHideEmulation.js » ('j') | lib/elemHideEmulation.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/coreUtils.js
===================================================================
--- a/lib/coreUtils.js
+++ b/lib/coreUtils.js
@@ -50,8 +50,40 @@
}
exports.findIndex = findIndex;
function indexOf(iterable, searchElement)
{
return findIndex(iterable, item => item === searchElement);
}
exports.indexOf = indexOf;
+
+function* filterIt(iterable, callback, thisArg)
Manish Jethani 2018/05/13 20:39:48 These are helper functions as described in Trac #6
+{
+ for (let item of iterable)
+ {
+ if (callback.call(thisArg, item))
+ yield item;
+ }
+}
+exports.filterIt = filterIt;
+
+function* mapIt(iterable, callback, thisArg)
+{
+ for (let item of iterable)
+ yield callback.call(thisArg, item);
+}
+exports.mapIt = mapIt;
+
+function* flattenIt(iterable, callback, thisArg)
+{
+ for (let item of iterable)
+ yield* item;
+}
+exports.flattenIt = flattenIt;
+
+function* regExpIt(regExp, string)
+{
+ let match = null;
+ while (match = regExp.exec(string))
+ yield match;
+}
+exports.regExpIt = regExpIt;
« no previous file with comments | « no previous file | lib/elemHideEmulation.js » ('j') | lib/elemHideEmulation.js » ('J')

Powered by Google App Engine
This is Rietveld