| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WTF_AtomicStringTable_h | 5 #ifndef WTF_AtomicStringTable_h |
| 6 #define WTF_AtomicStringTable_h | 6 #define WTF_AtomicStringTable_h |
| 7 | 7 |
| 8 #include "wtf/Allocator.h" | 8 #include "wtf/Allocator.h" |
| 9 #include "wtf/HashSet.h" | 9 #include "wtf/HashSet.h" |
| 10 #include "wtf/WTFExport.h" | 10 #include "wtf/WTFExport.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 ~AtomicStringTable(); | 24 ~AtomicStringTable(); |
| 25 | 25 |
| 26 // Gets the shared table for the current thread. | 26 // Gets the shared table for the current thread. |
| 27 static AtomicStringTable& instance() | 27 static AtomicStringTable& instance() |
| 28 { | 28 { |
| 29 return wtfThreadData().getAtomicStringTable(); | 29 return wtfThreadData().getAtomicStringTable(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Used by system initialization to preallocate enough storage for all of | 32 // Used by system initialization to preallocate enough storage for all of |
| 33 // the static strings. | 33 // the static strings. |
| 34 void reserveCapacity(unsigned); | 34 void reserveCapacity(unsigned size); |
| 35 | 35 |
| 36 // Adding a StringImpl. | 36 // Inserting strings into the table. Note that the return value from adding |
| 37 // a UChar string may be an LChar string as the table will attempt to |
| 38 // convert the string to save memory if possible. |
| 37 StringImpl* add(StringImpl*); | 39 StringImpl* add(StringImpl*); |
| 38 PassRefPtr<StringImpl> add(StringImpl*, unsigned offset, unsigned length); | 40 PassRefPtr<StringImpl> add(const LChar* chars, unsigned length); |
| 39 | 41 PassRefPtr<StringImpl> add(const UChar* chars, unsigned length); |
| 40 // Adding an LChar. | |
| 41 PassRefPtr<StringImpl> add(const LChar*, unsigned length); | |
| 42 | |
| 43 // Adding a UChar. | |
| 44 PassRefPtr<StringImpl> add(const UChar*, unsigned length); | |
| 45 PassRefPtr<StringImpl> add(const UChar*, unsigned length, unsigned existingH
ash); | |
| 46 PassRefPtr<StringImpl> add(const UChar*); | |
| 47 | 42 |
| 48 // Adding UTF8. | 43 // Adding UTF8. |
| 49 // Returns null if the characters contain invalid utf8 sequences. | 44 // Returns null if the characters contain invalid utf8 sequences. |
| 50 // Pass null for the charactersEnd to automatically detect the length. | 45 // Pass null for the charactersEnd to automatically detect the length. |
| 51 PassRefPtr<StringImpl> addUTF8(const char* charactersStart, const char* char
actersEnd); | 46 PassRefPtr<StringImpl> addUTF8(const char* charactersStart, const char* char
actersEnd); |
| 52 | 47 |
| 53 // This is for ~StringImpl to unregister a string before destruction since | 48 // This is for ~StringImpl to unregister a string before destruction since |
| 54 // the table is holding weak pointers. It should not be used directly. | 49 // the table is holding weak pointers. It should not be used directly. |
| 55 void remove(StringImpl*); | 50 void remove(StringImpl*); |
| 56 | 51 |
| 57 private: | 52 private: |
| 58 template<typename T, typename HashTranslator> | 53 template<typename T, typename HashTranslator> |
| 59 inline PassRefPtr<StringImpl> addToStringTable(const T& value); | 54 inline PassRefPtr<StringImpl> addToStringTable(const T& value); |
| 60 | 55 |
| 61 template<typename CharacterType> | |
| 62 inline HashSet<StringImpl*>::iterator find(const StringImpl*); | |
| 63 | |
| 64 HashSet<StringImpl*> m_table; | 56 HashSet<StringImpl*> m_table; |
| 65 }; | 57 }; |
| 66 | 58 |
| 67 } // namespace WTF | 59 } // namespace WTF |
| 68 | 60 |
| 69 using WTF::AtomicStringTable; | 61 using WTF::AtomicStringTable; |
| 70 | 62 |
| 71 #endif | 63 #endif |
| OLD | NEW |