Index: third_party/WebKit/Source/wtf/text/AtomicString.cpp |
diff --git a/third_party/WebKit/Source/wtf/text/AtomicString.cpp b/third_party/WebKit/Source/wtf/text/AtomicString.cpp |
index d3888ecf1577d73ab69106e8243c97982ea5ca59..b172895c2a4f028dadbf3cd8eccb217fe03e2ae8 100644 |
--- a/third_party/WebKit/Source/wtf/text/AtomicString.cpp |
+++ b/third_party/WebKit/Source/wtf/text/AtomicString.cpp |
@@ -39,14 +39,7 @@ static_assert(sizeof(AtomicString) == sizeof(String), "AtomicString and String m |
class AtomicStringTable { |
WTF_MAKE_NONCOPYABLE(AtomicStringTable); |
public: |
- static AtomicStringTable* create(WTFThreadData& data) |
- { |
- data.m_atomicStringTable = new AtomicStringTable; |
- data.m_atomicStringTableDestructor = AtomicStringTable::destroy; |
- data.m_atomicStringTable->addStaticStrings(); |
- return data.m_atomicStringTable; |
- } |
- |
+ AtomicStringTable() = default; |
StringImpl* addStringImpl(StringImpl* string) |
{ |
if (!string->length()) |
@@ -67,47 +60,41 @@ public: |
} |
private: |
- AtomicStringTable() { } |
- |
- void addStaticStrings() |
- { |
- const StaticStringsTable& staticStrings = StringImpl::allStaticStrings(); |
+ HashSet<StringImpl*> m_table; |
+}; |
- StaticStringsTable::const_iterator it = staticStrings.begin(); |
- for (; it != staticStrings.end(); ++it) { |
- addStringImpl(it->value); |
- } |
+AtomicStringTable* AtomicString::createAtomicStringTable() |
+{ |
+ AtomicStringTable* table = new AtomicStringTable; |
+ const StaticStringsTable& staticStrings = StringImpl::allStaticStrings(); |
+ for (auto it = staticStrings.begin(); it != staticStrings.end(); ++it) { |
+ table->addStringImpl(it->value); |
} |
+ return table; |
+} |
- static void destroy(AtomicStringTable* table) |
- { |
- HashSet<StringImpl*>::iterator end = table->m_table.end(); |
- for (HashSet<StringImpl*>::iterator iter = table->m_table.begin(); iter != end; ++iter) { |
- StringImpl* string = *iter; |
- if (!string->isStatic()) { |
- ASSERT(string->isAtomic()); |
- string->setIsAtomic(false); |
- } |
+void AtomicString::destroyAtomicStringTable(AtomicStringTable* table) |
+{ |
+ for (StringImpl* string : table->table()) { |
+ if (!string->isStatic()) { |
+ ASSERT(string->isAtomic()); |
+ string->setIsAtomic(false); |
} |
- delete table; |
} |
+ delete table; |
+} |
- HashSet<StringImpl*> m_table; |
-}; |
- |
-static inline AtomicStringTable& atomicStringTable() |
+static inline AtomicStringTable* atomicStringTable() |
{ |
- // Once possible we should make this non-lazy (constructed in WTFThreadData's constructor). |
WTFThreadData& data = wtfThreadData(); |
AtomicStringTable* table = data.atomicStringTable(); |
- if (UNLIKELY(!table)) |
- table = AtomicStringTable::create(data); |
- return *table; |
+ ASSERT(table); |
+ return table; |
} |
static inline HashSet<StringImpl*>& atomicStrings() |
{ |
- return atomicStringTable().table(); |
+ return atomicStringTable()->table(); |
} |
template<typename T, typename HashTranslator> |
@@ -405,7 +392,7 @@ PassRefPtr<StringImpl> AtomicString::addFromLiteralData(const char* characters, |
PassRefPtr<StringImpl> AtomicString::addSlowCase(StringImpl* string) |
{ |
- return atomicStringTable().addStringImpl(string); |
+ return atomicStringTable()->addStringImpl(string); |
} |
template<typename CharacterType> |