| 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-2017 eyeo GmbH | 3  * Copyright (C) 2006-2017 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 342   { | 342   { | 
| 343     if (!sourceLen) | 343     if (!sourceLen) | 
| 344       return; | 344       return; | 
| 345 | 345 | 
| 346     assert(source, u"Null buffer passed to OwnedString.append()"_str); | 346     assert(source, u"Null buffer passed to OwnedString.append()"_str); | 
| 347     size_t oldLength = length(); | 347     size_t oldLength = length(); | 
| 348     grow(sourceLen); | 348     grow(sourceLen); | 
| 349     std::memcpy(mBuf + oldLength, source, sizeof(value_type) * sourceLen); | 349     std::memcpy(mBuf + oldLength, source, sizeof(value_type) * sourceLen); | 
| 350   } | 350   } | 
| 351 | 351 | 
|  | 352   void append(const char* source, size_type sourceLen) | 
|  | 353   { | 
|  | 354     if (!sourceLen) | 
|  | 355       return; | 
|  | 356 | 
|  | 357     assert(source, u"Null buffer passed to OwnedString.append()"_str); | 
|  | 358     size_t oldLength = length(); | 
|  | 359     grow(sourceLen); | 
|  | 360     for (size_t i = 0; i < sourceLen; i++) | 
|  | 361       mBuf[oldLength + i] = source[i]; | 
|  | 362   } | 
|  | 363 | 
| 352   void append(const String& str) | 364   void append(const String& str) | 
| 353   { | 365   { | 
| 354     append(str.mBuf, str.length()); | 366     append(str.mBuf, str.length()); | 
| 355   } | 367   } | 
| 356 | 368 | 
| 357   void append(value_type c) | 369   void append(value_type c) | 
| 358   { | 370   { | 
| 359     append(&c, 1); | 371     append(&c, 1); | 
| 360   } | 372   } | 
| 361 | 373 | 
| 362   template<typename T, | 374   template<typename T, | 
| 363       typename std::enable_if<std::is_integral<T>::value>::type* = nullptr> | 375       typename std::enable_if<std::is_integral<T>::value>::type* = nullptr> | 
| 364   void append(T num) | 376   void append(T num) | 
| 365   { | 377   { | 
| 366     bool negative = false; | 378     bool negative = false; | 
| 367     if (num < 0) | 379     if (num < 0) | 
| 368     { | 380     { | 
| 369       negative = true; | 381       negative = true; | 
| 370       num = -num; | 382       num = -num; | 
| 371     } | 383     } | 
| 372 | 384 | 
| 373     size_type size = 0; | 385     size_type size = 0; | 
| 374     for (int i = num; i; i /= 10) | 386     for (T i = num; i; i /= 10) | 
| 375       size++; | 387       size++; | 
| 376     size = (size ? size : 1); | 388     size = (size ? size : 1); | 
| 377 | 389 | 
| 378     size_type pos = length(); | 390     size_type pos = length(); | 
| 379     grow((negative ? 1 : 0) + size); | 391     grow((negative ? 1 : 0) + size); | 
| 380 | 392 | 
| 381     if (negative) | 393     if (negative) | 
| 382       mBuf[pos++] = '-'; | 394       mBuf[pos++] = '-'; | 
| 383 | 395 | 
| 384     for (int i = size - 1; i >= 0; i--) | 396     for (int i = size - 1; i >= 0; i--) | 
| 385     { | 397     { | 
| 386       mBuf[pos + i] = '0' + (num % 10); | 398       mBuf[pos + i] = '0' + (num % 10); | 
| 387       num /= 10; | 399       num /= 10; | 
| 388     } | 400     } | 
| 389   } | 401   } | 
| 390 }; | 402 }; | 
| OLD | NEW | 
|---|