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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 JSNotifySubscriptionChange: function(topic, subscription) 54 JSNotifySubscriptionChange: function(topic, subscription)
55 { 55 {
56 FilterNotifier.triggerListeners(notifierTopics.get(topic), 56 FilterNotifier.triggerListeners(notifierTopics.get(topic),
57 exports.Subscription.fromPointer(subscription)); 57 exports.Subscription.fromPointer(subscription));
58 }, 58 },
59 59
60 $_regexp_data: Object.create(null), 60 $_regexp_data: Object.create(null),
61 $_regexp_counter: 0, 61 $_regexp_counter: 0,
62 62
63 GenerateRegExp__deps: ["$_regexp_data", "$_regexp_counter"], 63 GenerateRegExp__deps: ["$_regexp_data", "$_regexp_counter"],
64 GenerateRegExp: function(source, matchCase) 64 GenerateRegExp: function(source, matchCase, global)
65 { 65 {
66 var id = ++_regexp_counter; 66 var id = ++_regexp_counter;
67 try 67 try
68 { 68 {
69 _regexp_data[id] = new RegExp(readString(source), matchCase ? "" : "i"); 69 var flag = matchCase ? "" : "i";
70 if (global)
71 flag += "g";
72 _regexp_data[id] = new RegExp(readString(source), flag);
70 return id; 73 return id;
71 } 74 }
72 catch (e) 75 catch (e)
73 { 76 {
74 return -1; 77 return -1;
75 } 78 }
76 }, 79 },
77 80
78 DeleteRegExp__deps: ["$_regexp_data"], 81 DeleteRegExp__deps: ["$_regexp_data"],
79 DeleteRegExp: function(id) 82 DeleteRegExp: function(id)
80 { 83 {
81 delete _regexp_data[id]; 84 delete _regexp_data[id];
82 }, 85 },
83 86
84 TestRegExp__deps: ["$_regexp_data"], 87 TestRegExp__deps: ["$_regexp_data"],
85 TestRegExp: function(id, str) 88 TestRegExp: function(id, str)
86 { 89 {
87 return _regexp_data[id].test(readString(str)); 90 return _regexp_data[id].test(readString(str));
91 },
92
93 ExecRegExp__deps: ["$_regexp_data"],
94 ExecRegExp: function(id, str)
95 {
96 var match = _regexp_data[id].exec(readString(str));
97 if (match)
98 return match.index;
99 return -1;
100 },
101
102 MatchRegExp__deps: ["$_regexp_data"],
103 MatchRegExp: function(id, str, reMatchResults)
104 {
105 var string = readString(str);
106 var result = new exports.ReMatchResults(reMatchResults);
107 var matches = string.match(_regexp_data[id]);
108 if (!matches)
109 return false;
110 for (var i = 0; i < matches.length; i++)
111 result.push(matches[i]);
112 return true;
88 } 113 }
89 }); 114 });
OLDNEW
« 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