| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
reserved. |
| 4 * Copyright (C) 2009 Google Inc. All rights reserved. | 4 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 // StringImpls are allocated out of the WTF buffer partition. | 120 // StringImpls are allocated out of the WTF buffer partition. |
| 121 void* operator new(size_t); | 121 void* operator new(size_t); |
| 122 void* operator new(size_t, void* ptr) { return ptr; }; | 122 void* operator new(size_t, void* ptr) { return ptr; }; |
| 123 void operator delete(void*); | 123 void operator delete(void*); |
| 124 | 124 |
| 125 // Used to construct static strings, which have an special refCount that can
never hit zero. | 125 // Used to construct static strings, which have an special refCount that can
never hit zero. |
| 126 // This means that the static string will never be destroyed, which is impor
tant because | 126 // This means that the static string will never be destroyed, which is impor
tant because |
| 127 // static strings will be shared across threads & ref-counted in a non-threa
dsafe manner. | 127 // static strings will be shared across threads & ref-counted in a non-threa
dsafe manner. |
| 128 enum ConstructEmptyStringTag { ConstructEmptyString }; | 128 enum ConstructEmptyStringTag { ConstructEmpty8BitString, ConstructEmpty16Bit
String }; |
| 129 explicit StringImpl(ConstructEmptyStringTag) | 129 explicit StringImpl(ConstructEmptyStringTag tag) |
| 130 : m_refCount(1) | 130 : m_refCount(1) |
| 131 , m_length(0) | 131 , m_length(0) |
| 132 , m_hash(0) | 132 , m_hash(0) |
| 133 , m_isAtomic(false) | 133 , m_isAtomic(false) |
| 134 , m_is8Bit(true) | 134 , m_is8Bit(tag == ConstructEmpty8BitString) |
| 135 , m_isStatic(true) | 135 , m_isStatic(true) |
| 136 { | 136 { |
| 137 // Ensure that the hash is computed so that AtomicStringHash can call ex
istingHash() | 137 // Ensure that the hash is computed so that AtomicStringHash can call ex
istingHash() |
| 138 // with impunity. The empty string is special because it is never entere
d into | 138 // with impunity. The empty string is special because it is never entere
d into |
| 139 // AtomicString's HashKey, but still needs to compare correctly. | 139 // AtomicString's HashKey, but still needs to compare correctly. |
| 140 STRING_STATS_ADD_8BIT_STRING(m_length); | 140 STRING_STATS_ADD_8BIT_STRING(m_length); |
| 141 hash(); | 141 hash(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // FIXME: there has to be a less hacky way to do this. | 144 // FIXME: there has to be a less hacky way to do this. |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 ALWAYS_INLINE void deref() | 283 ALWAYS_INLINE void deref() |
| 284 { | 284 { |
| 285 if (hasOneRef()) { | 285 if (hasOneRef()) { |
| 286 destroyIfNotStatic(); | 286 destroyIfNotStatic(); |
| 287 return; | 287 return; |
| 288 } | 288 } |
| 289 | 289 |
| 290 --m_refCount; | 290 --m_refCount; |
| 291 } | 291 } |
| 292 | 292 |
| 293 static StringImpl* empty(); | 293 static StringImpl* empty(bool is8Bit = true); |
| 294 | 294 |
| 295 // FIXME: Does this really belong in StringImpl? | 295 // FIXME: Does this really belong in StringImpl? |
| 296 template <typename T> static void copyChars(T* destination, const T* source,
unsigned numCharacters) | 296 template <typename T> static void copyChars(T* destination, const T* source,
unsigned numCharacters) |
| 297 { | 297 { |
| 298 memcpy(destination, source, numCharacters * sizeof(T)); | 298 memcpy(destination, source, numCharacters * sizeof(T)); |
| 299 } | 299 } |
| 300 | 300 |
| 301 ALWAYS_INLINE static void copyChars(UChar* destination, const LChar* source,
unsigned numCharacters) | 301 ALWAYS_INLINE static void copyChars(UChar* destination, const LChar* source,
unsigned numCharacters) |
| 302 { | 302 { |
| 303 for (unsigned i = 0; i < numCharacters; ++i) | 303 for (unsigned i = 0; i < numCharacters; ++i) |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 } | 731 } |
| 732 | 732 |
| 733 using WTF::StringImpl; | 733 using WTF::StringImpl; |
| 734 using WTF::equal; | 734 using WTF::equal; |
| 735 using WTF::equalNonNull; | 735 using WTF::equalNonNull; |
| 736 using WTF::TextCaseSensitivity; | 736 using WTF::TextCaseSensitivity; |
| 737 using WTF::TextCaseSensitive; | 737 using WTF::TextCaseSensitive; |
| 738 using WTF::TextCaseInsensitive; | 738 using WTF::TextCaseInsensitive; |
| 739 | 739 |
| 740 #endif | 740 #endif |
| OLD | NEW |