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

Side by Side Diff: compiled/String.h

Issue 29606600: Issue 5146 - Implement DownloadableSubscription parsing in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Simplify the logic of Process() Created Dec. 4, 2017, 10:04 a.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 | « compiled/Md5.cpp ('k') | compiled/StringScanner.h » ('j') | no next file with comments »
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
(...skipping 173 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 184 // This should be more efficient with a lookup table but I couldn't measur e
185 // any performance difference. 185 // any performance difference.
186 if (currChar >= u'A' && currChar <= u'Z') 186 if (currChar >= u'A' && currChar <= u'Z')
187 mBuf[i] = currChar + u'a' - u'A'; 187 mBuf[i] = currChar + u'a' - u'A';
188 else if (currChar >= 128) 188 else if (currChar >= 128)
189 { 189 {
190 mBuf[i] = CharToLower(currChar); 190 mBuf[i] = CharToLower(currChar);
191 } 191 }
192 } 192 }
193 } 193 }
194
195 template<typename T>
196 T toInt() const
197 {
198 size_type count = 0;
199 T value = 0;
200 for (size_type i = 0; i < length(); i++)
201 {
202 if (mBuf[i] < u'0' || mBuf[i] > u'9' ||
203 count > std::numeric_limits<T>::digits10)
204 return 0;
205
206 value *= 10;
207 value += mBuf[i] - u'0';
208 count++;
209 }
210 return value;
211 }
194 }; 212 };
195 213
196 class DependentString : public String 214 class DependentString : public String
197 { 215 {
198 public: 216 public:
199 explicit DependentString() 217 explicit DependentString()
200 : String(nullptr, 0, INVALID) 218 : String(nullptr, 0, INVALID)
201 { 219 {
202 } 220 }
203 221
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 if (negative) 421 if (negative)
404 mBuf[pos++] = '-'; 422 mBuf[pos++] = '-';
405 423
406 for (int i = size - 1; i >= 0; i--) 424 for (int i = size - 1; i >= 0; i--)
407 { 425 {
408 mBuf[pos + i] = '0' + (num % 10); 426 mBuf[pos + i] = '0' + (num % 10);
409 num /= 10; 427 num /= 10;
410 } 428 }
411 } 429 }
412 }; 430 };
OLDNEW
« no previous file with comments | « compiled/Md5.cpp ('k') | compiled/StringScanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld