| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return create8BitIfPossible(vector.data(), vector.size()); | 211 return create8BitIfPossible(vector.data(), vector.size()); |
| 212 } | 212 } |
| 213 | 213 |
| 214 ALWAYS_INLINE static PassRefPtr<StringImpl> create(const char* s, unsigned l
ength) { return create(reinterpret_cast<const LChar*>(s), length); } | 214 ALWAYS_INLINE static PassRefPtr<StringImpl> create(const char* s, unsigned l
ength) { return create(reinterpret_cast<const LChar*>(s), length); } |
| 215 static PassRefPtr<StringImpl> create(const LChar*); | 215 static PassRefPtr<StringImpl> create(const LChar*); |
| 216 ALWAYS_INLINE static PassRefPtr<StringImpl> create(const char* s) { return c
reate(reinterpret_cast<const LChar*>(s)); } | 216 ALWAYS_INLINE static PassRefPtr<StringImpl> create(const char* s) { return c
reate(reinterpret_cast<const LChar*>(s)); } |
| 217 | 217 |
| 218 static PassRefPtr<StringImpl> createUninitialized(unsigned length, LChar*& d
ata); | 218 static PassRefPtr<StringImpl> createUninitialized(unsigned length, LChar*& d
ata); |
| 219 static PassRefPtr<StringImpl> createUninitialized(unsigned length, UChar*& d
ata); | 219 static PassRefPtr<StringImpl> createUninitialized(unsigned length, UChar*& d
ata); |
| 220 | 220 |
| 221 // If this StringImpl has only one reference, we can truncate the string by | |
| 222 // updating its m_length property without actually re-allocating its buffer. | |
| 223 void truncateAssumingIsolated(unsigned length) | |
| 224 { | |
| 225 ASSERT(hasOneRef()); | |
| 226 ASSERT(length <= m_length); | |
| 227 m_length = length; | |
| 228 } | |
| 229 | |
| 230 unsigned length() const { return m_length; } | 221 unsigned length() const { return m_length; } |
| 231 bool is8Bit() const { return m_is8Bit; } | 222 bool is8Bit() const { return m_is8Bit; } |
| 232 | 223 |
| 233 ALWAYS_INLINE const LChar* characters8() const { ASSERT(is8Bit()); return re
interpret_cast<const LChar*>(this + 1); } | 224 ALWAYS_INLINE const LChar* characters8() const { ASSERT(is8Bit()); return re
interpret_cast<const LChar*>(this + 1); } |
| 234 ALWAYS_INLINE const UChar* characters16() const { ASSERT(!is8Bit()); return
reinterpret_cast<const UChar*>(this + 1); } | 225 ALWAYS_INLINE const UChar* characters16() const { ASSERT(!is8Bit()); return
reinterpret_cast<const UChar*>(this + 1); } |
| 235 | 226 |
| 236 template <typename CharType> | 227 template <typename CharType> |
| 237 ALWAYS_INLINE const CharType * getCharacters() const; | 228 ALWAYS_INLINE const CharType * getCharacters() const; |
| 238 | 229 |
| 239 size_t sizeInBytes() const; | 230 size_t sizeInBytes() const; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 #if ENABLE(ASSERT) | 436 #if ENABLE(ASSERT) |
| 446 void assertHashIsCorrect() | 437 void assertHashIsCorrect() |
| 447 { | 438 { |
| 448 ASSERT(hasHash()); | 439 ASSERT(hasHash()); |
| 449 ASSERT(existingHash() == StringHasher::computeHashAndMaskTop8Bits(charac
ters8(), length())); | 440 ASSERT(existingHash() == StringHasher::computeHashAndMaskTop8Bits(charac
ters8(), length())); |
| 450 } | 441 } |
| 451 #endif | 442 #endif |
| 452 | 443 |
| 453 private: | 444 private: |
| 454 unsigned m_refCount; | 445 unsigned m_refCount; |
| 455 unsigned m_length; | 446 const unsigned m_length; |
| 456 mutable unsigned m_hash : 24; | 447 mutable unsigned m_hash : 24; |
| 457 unsigned m_isAtomic : 1; | 448 unsigned m_isAtomic : 1; |
| 458 unsigned m_is8Bit : 1; | 449 const unsigned m_is8Bit : 1; |
| 459 unsigned m_isStatic : 1; | 450 const unsigned m_isStatic : 1; |
| 460 }; | 451 }; |
| 461 | 452 |
| 462 template <> | 453 template <> |
| 463 ALWAYS_INLINE const LChar* StringImpl::getCharacters<LChar>() const { return cha
racters8(); } | 454 ALWAYS_INLINE const LChar* StringImpl::getCharacters<LChar>() const { return cha
racters8(); } |
| 464 | 455 |
| 465 template <> | 456 template <> |
| 466 ALWAYS_INLINE const UChar* StringImpl::getCharacters<UChar>() const { return cha
racters16(); } | 457 ALWAYS_INLINE const UChar* StringImpl::getCharacters<UChar>() const { return cha
racters16(); } |
| 467 | 458 |
| 468 WTF_EXPORT bool equal(const StringImpl*, const StringImpl*); | 459 WTF_EXPORT bool equal(const StringImpl*, const StringImpl*); |
| 469 WTF_EXPORT bool equal(const StringImpl*, const LChar*); | 460 WTF_EXPORT bool equal(const StringImpl*, const LChar*); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 } | 768 } |
| 778 | 769 |
| 779 using WTF::StringImpl; | 770 using WTF::StringImpl; |
| 780 using WTF::equal; | 771 using WTF::equal; |
| 781 using WTF::equalNonNull; | 772 using WTF::equalNonNull; |
| 782 using WTF::TextCaseSensitivity; | 773 using WTF::TextCaseSensitivity; |
| 783 using WTF::TextCaseSensitive; | 774 using WTF::TextCaseSensitive; |
| 784 using WTF::TextCaseInsensitive; | 775 using WTF::TextCaseInsensitive; |
| 785 | 776 |
| 786 #endif | 777 #endif |
| OLD | NEW |