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

Delta Between Two Patch Sets: compiled/String.h

Issue 29556737: Issue 5141 - Convert filter match to C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Sept. 26, 2017, 9:34 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « 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')
LEFTRIGHT
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 12 matching lines...) Expand all
23 #include <type_traits> 23 #include <type_traits>
24 #include <vector> 24 #include <vector>
25 25
26 #include "debug.h" 26 #include "debug.h"
27 #include "library.h" 27 #include "library.h"
28 #include "intrusive_ptr.h" 28 #include "intrusive_ptr.h"
29 #include "bindings/runtime.h" 29 #include "bindings/runtime.h"
30 30
31 inline void String_assert_writable(bool isWritable); 31 inline void String_assert_writable(bool isWritable);
32 32
33 class OwnedString; 33 class DependentString;
34 class ReMatchResults; 34 class ReMatchResults;
35 35
36 class String 36 class String
37 { 37 {
38 friend class DependentString; 38 friend class DependentString;
39 friend class OwnedString; 39 friend class OwnedString;
40 40
41 public: 41 public:
42 typedef char16_t value_type; 42 typedef char16_t value_type;
43 typedef size_t size_type; 43 typedef size_t size_type;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // any performance difference. 191 // any performance difference.
192 if (currChar >= u'A' && currChar <= u'Z') 192 if (currChar >= u'A' && currChar <= u'Z')
193 mBuf[i] = currChar + u'a' - u'A'; 193 mBuf[i] = currChar + u'a' - u'A';
194 else if (currChar >= 128) 194 else if (currChar >= 128)
195 { 195 {
196 mBuf[i] = CharToLower(currChar); 196 mBuf[i] = CharToLower(currChar);
197 } 197 }
198 } 198 }
199 } 199 }
200 200
201 OwnedString substr(size_type pos, size_type len = npos) const; 201 bool match(int id, ReMatchResults& results) const
202 bool match(int id, ReMatchResults*) const; 202 {
hub 2017/09/26 21:48:59 String API that mimic JS string API.
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
203 }; 205 };
204 206
205 class DependentString : public String 207 class DependentString : public String
206 { 208 {
207 public: 209 public:
208 explicit DependentString() 210 explicit DependentString()
209 : String(nullptr, 0, INVALID) 211 : String(nullptr, 0, INVALID)
210 { 212 {
211 } 213 }
212 214
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 411
410 for (int i = size - 1; i >= 0; i--) 412 for (int i = size - 1; i >= 0; i--)
411 { 413 {
412 mBuf[pos + i] = '0' + (num % 10); 414 mBuf[pos + i] = '0' + (num % 10);
413 num /= 10; 415 num /= 10;
414 } 416 }
415 } 417 }
416 }; 418 };
417 419
418 // Utility class to get match from JS code in library.js 420 // Utility class to get match from JS code in library.js
419 class ReMatchResults : public ref_counted 421 class ReMatchResults : public ref_counted
hub 2017/09/26 21:48:59 This it the hack to be able to get the array of st
sergei 2017/10/02 12:02:32 I thin it's fine, I had experienced a demand in so
420 { 422 {
421 public: 423 public:
422 void BINDINGS_EXPORTED push(OwnedString&& s) 424 void BINDINGS_EXPORTED push(const String& s)
423 { 425 {
424 candidates.push_back(s); 426 candidates.push_back(OwnedString(s));
425 } 427 }
426 std::vector<OwnedString> candidates; 428 std::vector<OwnedString> candidates;
427 }; 429 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld