| 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" |
| 11 #include "wtf/WTFThreadData.h" | 11 #include "wtf/WTFThreadData.h" |
| 12 #include "wtf/text/StringHash.h" | 12 #include "wtf/text/StringHash.h" |
| 13 #include "wtf/text/StringImpl.h" | 13 #include "wtf/text/StringImpl.h" |
| 14 | 14 |
| 15 namespace WTF { | 15 namespace WTF { |
| 16 | 16 |
| 17 // The underlying storage that keeps the map of unique AtomicStrings. This is | 17 // The underlying storage that keeps the map of unique AtomicStrings. This is |
| 18 // not thread safe and each WTFThreadData has one. | 18 // not thread safe and each WTFThreadData has one. |
| 19 class WTF_EXPORT AtomicStringTable final { | 19 class WTF_EXPORT AtomicStringTable final { |
| 20 USING_FAST_MALLOC(AtomicStringTable); | 20 USING_FAST_MALLOC(AtomicStringTable); |
| 21 WTF_MAKE_NONCOPYABLE(AtomicStringTable); | 21 WTF_MAKE_NONCOPYABLE(AtomicStringTable); |
| 22 | 22 |
| 23 public: | 23 public: |
| 24 AtomicStringTable(); | 24 AtomicStringTable(); |
| 25 ~AtomicStringTable(); | 25 ~AtomicStringTable(); |
| 26 | 26 |
| 27 // Gets the shared table for the current thread. | 27 // Gets the shared table for the current thread. |
| 28 static AtomicStringTable& instance() { | 28 static AtomicStringTable& instance() { |
| 29 return wtfThreadData().getAtomicStringTable(); | 29 return WTFThreadData::current().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 size); | 34 void reserveCapacity(unsigned size); |
| 35 | 35 |
| 36 // Inserting strings into the table. Note that the return value from adding | 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 | 37 // a UChar string may be an LChar string as the table will attempt to |
| 38 // convert the string to save memory if possible. | 38 // convert the string to save memory if possible. |
| 39 StringImpl* add(StringImpl*); | 39 StringImpl* add(StringImpl*); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 55 inline PassRefPtr<StringImpl> addToStringTable(const T& value); | 55 inline PassRefPtr<StringImpl> addToStringTable(const T& value); |
| 56 | 56 |
| 57 HashSet<StringImpl*> m_table; | 57 HashSet<StringImpl*> m_table; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace WTF | 60 } // namespace WTF |
| 61 | 61 |
| 62 using WTF::AtomicStringTable; | 62 using WTF::AtomicStringTable; |
| 63 | 63 |
| 64 #endif | 64 #endif |
| OLD | NEW |