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

Unified Diff: compiled/library.js

Issue 29556737: Issue 5141 - Convert filter match to C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Fixed many issues. One test left out. Created Oct. 6, 2017, 1:45 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
Index: compiled/library.js
===================================================================
--- a/compiled/library.js
+++ b/compiled/library.js
@@ -56,22 +56,25 @@
FilterNotifier.triggerListeners(notifierTopics.get(topic),
exports.Subscription.fromPointer(subscription));
},
$_regexp_data: Object.create(null),
$_regexp_counter: 0,
GenerateRegExp__deps: ["$_regexp_data", "$_regexp_counter"],
- GenerateRegExp: function(source, matchCase)
+ GenerateRegExp: function(source, matchCase, global)
{
var id = ++_regexp_counter;
try
{
- _regexp_data[id] = new RegExp(readString(source), matchCase ? "" : "i");
+ var flag = matchCase ? "" : "i";
+ if (global)
+ flag += "g";
+ _regexp_data[id] = new RegExp(readString(source), flag);
return id;
}
catch (e)
{
return -1;
}
},
@@ -80,10 +83,32 @@
{
delete _regexp_data[id];
},
TestRegExp__deps: ["$_regexp_data"],
TestRegExp: function(id, str)
{
return _regexp_data[id].test(readString(str));
+ },
+
+ ExecRegExp__deps: ["$_regexp_data"],
+ ExecRegExp: function(id, str)
+ {
+ var match = _regexp_data[id].exec(readString(str));
+ if (match)
+ return match.index;
+ return -1;
+ },
+
+ MatchRegExp__deps: ["$_regexp_data"],
+ MatchRegExp: function(id, str, reMatchResults)
+ {
+ var string = readString(str);
+ var result = new exports.ReMatchResults(reMatchResults);
+ var matches = string.match(_regexp_data[id]);
+ if (!matches)
+ return false;
+ for (var i = 0; i < matches.length; i++)
+ result.push(matches[i]);
+ return true;
}
});
« compiled/filter/Matcher.cpp ('K') | « compiled/library.h ('k') | lib/matcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld