| OLD | NEW |
| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 inline DependentString operator "" _str(const String::value_type* str, | 260 inline DependentString operator "" _str(const String::value_type* str, |
| 261 String::size_type len) | 261 String::size_type len) |
| 262 { | 262 { |
| 263 return DependentString(str, len); | 263 return DependentString(str, len); |
| 264 } | 264 } |
| 265 | 265 |
| 266 inline void String_assert_writable(bool isWritable) | 266 inline void String_assert_writable(bool isWritable) |
| 267 { | 267 { |
| 268 assert(isWritable, u"Writing access to a read-only string"_str); | 268 assert2(isWritable, u"Writing access to a read-only string"_str); |
| 269 } | 269 } |
| 270 | 270 |
| 271 class OwnedString : public String | 271 class OwnedString : public String |
| 272 { | 272 { |
| 273 private: | 273 private: |
| 274 void grow(size_type additionalSize) | 274 void grow(size_type additionalSize) |
| 275 { | 275 { |
| 276 OwnedString newValue(length() + additionalSize); | 276 OwnedString newValue(length() + additionalSize); |
| 277 if (length() > 0) | 277 if (length() > 0) |
| 278 std::memcpy(newValue.mBuf, mBuf, sizeof(value_type) * length()); | 278 std::memcpy(newValue.mBuf, mBuf, sizeof(value_type) * length()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 std::swap(mBuf, str.mBuf); | 341 std::swap(mBuf, str.mBuf); |
| 342 std::swap(mLen, str.mLen); | 342 std::swap(mLen, str.mLen); |
| 343 return *this; | 343 return *this; |
| 344 } | 344 } |
| 345 | 345 |
| 346 void append(const value_type* source, size_type sourceLen) | 346 void append(const value_type* source, size_type sourceLen) |
| 347 { | 347 { |
| 348 if (!sourceLen) | 348 if (!sourceLen) |
| 349 return; | 349 return; |
| 350 | 350 |
| 351 assert(source, u"Null buffer passed to OwnedString.append()"_str); | 351 assert2(source, u"Null buffer passed to OwnedString.append()"_str); |
| 352 size_t oldLength = length(); | 352 size_t oldLength = length(); |
| 353 grow(sourceLen); | 353 grow(sourceLen); |
| 354 std::memcpy(mBuf + oldLength, source, sizeof(value_type) * sourceLen); | 354 std::memcpy(mBuf + oldLength, source, sizeof(value_type) * sourceLen); |
| 355 } | 355 } |
| 356 | 356 |
| 357 void append(const char* source, size_type sourceLen) | 357 void append(const char* source, size_type sourceLen) |
| 358 { | 358 { |
| 359 if (!sourceLen) | 359 if (!sourceLen) |
| 360 return; | 360 return; |
| 361 | 361 |
| 362 assert(source, u"Null buffer passed to OwnedString.append()"_str); | 362 assert2(source, u"Null buffer passed to OwnedString.append()"_str); |
| 363 size_t oldLength = length(); | 363 size_t oldLength = length(); |
| 364 grow(sourceLen); | 364 grow(sourceLen); |
| 365 for (size_t i = 0; i < sourceLen; i++) | 365 for (size_t i = 0; i < sourceLen; i++) |
| 366 mBuf[oldLength + i] = source[i]; | 366 mBuf[oldLength + i] = source[i]; |
| 367 } | 367 } |
| 368 | 368 |
| 369 void append(const String& str) | 369 void append(const String& str) |
| 370 { | 370 { |
| 371 append(str.mBuf, str.length()); | 371 append(str.mBuf, str.length()); |
| 372 } | 372 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 398 if (negative) | 398 if (negative) |
| 399 mBuf[pos++] = '-'; | 399 mBuf[pos++] = '-'; |
| 400 | 400 |
| 401 for (int i = size - 1; i >= 0; i--) | 401 for (int i = size - 1; i >= 0; i--) |
| 402 { | 402 { |
| 403 mBuf[pos + i] = '0' + (num % 10); | 403 mBuf[pos + i] = '0' + (num % 10); |
| 404 num /= 10; | 404 num /= 10; |
| 405 } | 405 } |
| 406 } | 406 } |
| 407 }; | 407 }; |
| OLD | NEW |