| 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 <algorithm> | 
| 21 #include <cstddef> | 21 #include <cstddef> | 
| 22 #include <cstring> | 22 #include <cstring> | 
| 23 #include <type_traits> | 23 #include <type_traits> | 
| 24 | 24 | 
| 25 #include <emscripten.h> |  | 
| 26 |  | 
| 27 #include "debug.h" | 25 #include "debug.h" | 
|  | 26 #include "library.h" | 
| 28 | 27 | 
| 29 inline void String_assert_readonly(bool readOnly); | 28 inline void String_assert_readonly(bool readOnly); | 
| 30 | 29 | 
| 31 class String | 30 class String | 
| 32 { | 31 { | 
| 33   friend class DependentString; | 32   friend class DependentString; | 
| 34   friend class OwnedString; | 33   friend class OwnedString; | 
| 35 | 34 | 
| 36 public: | 35 public: | 
| 37   typedef char16_t value_type; | 36   typedef char16_t value_type; | 
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 181     for (size_type i = 0; i < len; ++i) | 180     for (size_type i = 0; i < len; ++i) | 
| 182     { | 181     { | 
| 183       value_type currChar = mBuf[i]; | 182       value_type currChar = mBuf[i]; | 
| 184 | 183 | 
| 185       // 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 | 
| 186       // any performance difference. | 185       // any performance difference. | 
| 187       if (currChar >= u'A' && currChar <= u'Z') | 186       if (currChar >= u'A' && currChar <= u'Z') | 
| 188         mBuf[i] = currChar + u'a' - u'A'; | 187         mBuf[i] = currChar + u'a' - u'A'; | 
| 189       else if (currChar >= 128) | 188       else if (currChar >= 128) | 
| 190       { | 189       { | 
| 191         // It seems that calling JS is the easiest solution for lowercasing | 190         mBuf[i] = CharToLower(currChar); | 
| 192         // Unicode characters. |  | 
| 193         mBuf[i] = EM_ASM_INT({ |  | 
| 194           return String.fromCharCode($0).toLowerCase().charCodeAt(0); |  | 
| 195         }, currChar); |  | 
| 196       } | 191       } | 
| 197     } | 192     } | 
| 198   } | 193   } | 
| 199 }; | 194 }; | 
| 200 | 195 | 
| 201 class DependentString : public String | 196 class DependentString : public String | 
| 202 { | 197 { | 
| 203 public: | 198 public: | 
| 204   explicit DependentString() | 199   explicit DependentString() | 
| 205       : String(nullptr, 0, INVALID) | 200       : String(nullptr, 0, INVALID) | 
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 403     if (negative) | 398     if (negative) | 
| 404       mBuf[pos++] = '-'; | 399       mBuf[pos++] = '-'; | 
| 405 | 400 | 
| 406     for (int i = size - 1; i >= 0; i--) | 401     for (int i = size - 1; i >= 0; i--) | 
| 407     { | 402     { | 
| 408       mBuf[pos + i] = '0' + (num % 10); | 403       mBuf[pos + i] = '0' + (num % 10); | 
| 409       num /= 10; | 404       num /= 10; | 
| 410     } | 405     } | 
| 411   } | 406   } | 
| 412 }; | 407 }; | 
| OLD | NEW | 
|---|