| 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 | 
|   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 <cstddef> |   21 #include <cstddef> | 
|   21 #include <cstring> |   22 #include <cstring> | 
|   22 #include <algorithm> |   23 #include <type_traits> | 
|   23  |   24  | 
|   24 #include <emscripten.h> |   25 #include <emscripten.h> | 
|   25  |   26  | 
|   26 #include "debug.h" |   27 #include "debug.h" | 
|   27  |   28  | 
|   28 inline void String_assert_readonly(bool readOnly); |   29 inline void String_assert_readonly(bool readOnly); | 
|   29  |   30  | 
|   30 class String |   31 class String | 
|   31 { |   32 { | 
|   32   friend class DependentString; |   33   friend class DependentString; | 
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  350  |  351  | 
|  351   void append(const String& str) |  352   void append(const String& str) | 
|  352   { |  353   { | 
|  353     append(str.mBuf, str.length()); |  354     append(str.mBuf, str.length()); | 
|  354   } |  355   } | 
|  355  |  356  | 
|  356   void append(value_type c) |  357   void append(value_type c) | 
|  357   { |  358   { | 
|  358     append(&c, 1); |  359     append(&c, 1); | 
|  359   } |  360   } | 
 |  361  | 
 |  362   template<typename T, | 
 |  363       typename std::enable_if<std::is_integral<T>::value>::type* = nullptr> | 
 |  364   void append(T num) | 
 |  365   { | 
 |  366     bool negative = false; | 
 |  367     if (num < 0) | 
 |  368     { | 
 |  369       negative = true; | 
 |  370       num = -num; | 
 |  371     } | 
 |  372  | 
 |  373     size_type size = 0; | 
 |  374     for (int i = num; i; i /= 10) | 
 |  375       size++; | 
 |  376     size = (size ? size : 1); | 
 |  377  | 
 |  378     size_type pos = length(); | 
 |  379     grow((negative ? 1 : 0) + size); | 
 |  380  | 
 |  381     if (negative) | 
 |  382       mBuf[pos++] = '-'; | 
 |  383  | 
 |  384     for (int i = size - 1; i >= 0; i--) | 
 |  385     { | 
 |  386       mBuf[pos + i] = '0' + (num % 10); | 
 |  387       num /= 10; | 
 |  388     } | 
 |  389   } | 
|  360 }; |  390 }; | 
| OLD | NEW |