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

Side by Side Diff: compiled/String.h

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
« no previous file with comments | « no previous file | compiled/StringMap.h » ('j') | compiled/StringMap.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #pragma once 18 #pragma once
19 19
20 #include <algorithm> 20 #include <algorithm>
21 #include <cstddef> 21 #include <cstddef>
22 #include <cstring> 22 #include <cstring>
23 #include <type_traits> 23 #include <type_traits>
24 #include <vector>
24 25
25 #include "debug.h" 26 #include "debug.h"
26 #include "library.h" 27 #include "library.h"
28 #include "intrusive_ptr.h"
29 #include "bindings/runtime.h"
27 30
28 inline void String_assert_writable(bool isWritable); 31 inline void String_assert_writable(bool isWritable);
29 32
33 class DependentString;
34 class ReMatchResults;
35
30 class String 36 class String
31 { 37 {
32 friend class DependentString; 38 friend class DependentString;
33 friend class OwnedString; 39 friend class OwnedString;
34 40
35 public: 41 public:
36 typedef char16_t value_type; 42 typedef char16_t value_type;
37 typedef size_t size_type; 43 typedef size_t size_type;
38 44
39 // Type flags, stored in the top 2 bits of the mLen member 45 // Type flags, stored in the top 2 bits of the mLen member
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // This should be more efficient with a lookup table but I couldn't measur e 190 // This should be more efficient with a lookup table but I couldn't measur e
185 // any performance difference. 191 // any performance difference.
186 if (currChar >= u'A' && currChar <= u'Z') 192 if (currChar >= u'A' && currChar <= u'Z')
187 mBuf[i] = currChar + u'a' - u'A'; 193 mBuf[i] = currChar + u'a' - u'A';
188 else if (currChar >= 128) 194 else if (currChar >= 128)
189 { 195 {
190 mBuf[i] = CharToLower(currChar); 196 mBuf[i] = CharToLower(currChar);
191 } 197 }
192 } 198 }
193 } 199 }
200
201 bool match(int id, ReMatchResults& results) const
202 {
203 return MatchRegExp(id, *this, results);
204 }
Wladimir Palant 2017/10/09 08:39:45 This functionality doesn't belong here, it isn't b
sergei 2017/10/09 15:27:51 I would suggest for the beginning simply remove th
194 }; 205 };
195 206
196 class DependentString : public String 207 class DependentString : public String
197 { 208 {
198 public: 209 public:
199 explicit DependentString() 210 explicit DependentString()
200 : String(nullptr, 0, INVALID) 211 : String(nullptr, 0, INVALID)
201 { 212 {
202 } 213 }
203 214
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (negative) 409 if (negative)
399 mBuf[pos++] = '-'; 410 mBuf[pos++] = '-';
400 411
401 for (int i = size - 1; i >= 0; i--) 412 for (int i = size - 1; i >= 0; i--)
402 { 413 {
403 mBuf[pos + i] = '0' + (num % 10); 414 mBuf[pos + i] = '0' + (num % 10);
404 num /= 10; 415 num /= 10;
405 } 416 }
406 } 417 }
407 }; 418 };
419
420 // Utility class to get match from JS code in library.js
421 class ReMatchResults : public ref_counted
422 {
423 public:
424 void BINDINGS_EXPORTED push(const String& s)
425 {
426 candidates.push_back(OwnedString(s));
427 }
428 std::vector<OwnedString> candidates;
429 };
OLDNEW
« no previous file with comments | « no previous file | compiled/StringMap.h » ('j') | compiled/StringMap.h » ('J')

Powered by Google App Engine
This is Rietveld