OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> | 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> |
4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 WTFThreadData& data = wtfThreadData(); | 69 WTFThreadData& data = wtfThreadData(); |
70 AtomicStringTable* table = data.atomicStringTable(); | 70 AtomicStringTable* table = data.atomicStringTable(); |
71 if (UNLIKELY(!table)) | 71 if (UNLIKELY(!table)) |
72 table = AtomicStringTable::create(data); | 72 table = AtomicStringTable::create(data); |
73 return table->table(); | 73 return table->table(); |
74 } | 74 } |
75 | 75 |
76 template<typename T, typename HashTranslator> | 76 template<typename T, typename HashTranslator> |
77 static inline PassRefPtr<StringImpl> addToStringTable(const T& value) | 77 static inline PassRefPtr<StringImpl> addToStringTable(const T& value) |
78 { | 78 { |
79 HashSet<StringImpl*>::AddResult addResult = stringTable().add<T, HashTransla
tor>(value); | 79 HashSet<StringImpl*>::AddResult addResult = stringTable().add<HashTranslator
>(value); |
80 | 80 |
81 // If the string is newly-translated, then we need to adopt it. | 81 // If the string is newly-translated, then we need to adopt it. |
82 // The boolean in the pair tells us if that is so. | 82 // The boolean in the pair tells us if that is so. |
83 return addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.ite
rator; | 83 return addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.ite
rator; |
84 } | 84 } |
85 | 85 |
86 struct CStringTranslator { | 86 struct CStringTranslator { |
87 static unsigned hash(const LChar* c) | 87 static unsigned hash(const LChar* c) |
88 { | 88 { |
89 return StringHasher::computeHashAndMaskTop8Bits(c); | 89 return StringHasher::computeHashAndMaskTop8Bits(c); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 if (result == r) | 387 if (result == r) |
388 r->setIsAtomic(true); | 388 r->setIsAtomic(true); |
389 ASSERT(!r->isStatic() || result->isStatic()); | 389 ASSERT(!r->isStatic() || result->isStatic()); |
390 return result; | 390 return result; |
391 } | 391 } |
392 | 392 |
393 template<typename CharacterType> | 393 template<typename CharacterType> |
394 static inline HashSet<StringImpl*>::iterator findString(const StringImpl* string
Impl) | 394 static inline HashSet<StringImpl*>::iterator findString(const StringImpl* string
Impl) |
395 { | 395 { |
396 HashAndCharacters<CharacterType> buffer = { stringImpl->existingHash(), stri
ngImpl->getCharacters<CharacterType>(), stringImpl->length() }; | 396 HashAndCharacters<CharacterType> buffer = { stringImpl->existingHash(), stri
ngImpl->getCharacters<CharacterType>(), stringImpl->length() }; |
397 return stringTable().find<HashAndCharacters<CharacterType>, HashAndCharacter
sTranslator<CharacterType> >(buffer); | 397 return stringTable().find<HashAndCharactersTranslator<CharacterType> >(buffe
r); |
398 } | 398 } |
399 | 399 |
400 AtomicStringImpl* AtomicString::find(const StringImpl* stringImpl) | 400 AtomicStringImpl* AtomicString::find(const StringImpl* stringImpl) |
401 { | 401 { |
402 ASSERT(stringImpl); | 402 ASSERT(stringImpl); |
403 ASSERT(stringImpl->existingHash()); | 403 ASSERT(stringImpl->existingHash()); |
404 | 404 |
405 if (!stringImpl->length()) | 405 if (!stringImpl->length()) |
406 return static_cast<AtomicStringImpl*>(StringImpl::empty()); | 406 return static_cast<AtomicStringImpl*>(StringImpl::empty()); |
407 | 407 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 } | 453 } |
454 | 454 |
455 #ifndef NDEBUG | 455 #ifndef NDEBUG |
456 void AtomicString::show() const | 456 void AtomicString::show() const |
457 { | 457 { |
458 m_string.show(); | 458 m_string.show(); |
459 } | 459 } |
460 #endif | 460 #endif |
461 | 461 |
462 } // namespace WTF | 462 } // namespace WTF |
OLD | NEW |