| 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..3141a86ef91e24f17d4a16ecdefe26d4eda2a297 100644
|
| --- a/third_party/WebKit/Source/wtf/text/AtomicString.cpp
|
| +++ b/third_party/WebKit/Source/wtf/text/AtomicString.cpp
|
| @@ -24,7 +24,6 @@
|
| #include "AtomicString.h"
|
|
|
| #include "StringHash.h"
|
| -#include "wtf/HashSet.h"
|
| #include "wtf/WTFThreadData.h"
|
| #include "wtf/dtoa.h"
|
| #include "wtf/text/IntegerToStringConversion.h"
|
| @@ -36,78 +35,52 @@ using namespace Unicode;
|
|
|
| static_assert(sizeof(AtomicString) == sizeof(String), "AtomicString and String must be same size");
|
|
|
| -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;
|
| - }
|
| -
|
| - StringImpl* addStringImpl(StringImpl* string)
|
| - {
|
| - if (!string->length())
|
| - return StringImpl::empty();
|
| -
|
| - StringImpl* result = *m_table.add(string).storedValue;
|
| -
|
| - if (!result->isAtomic())
|
| - result->setIsAtomic(true);
|
| -
|
| - ASSERT(!string->isStatic() || result->isStatic());
|
| - return result;
|
| - }
|
| +StringImpl* AtomicStringTable::addStringImpl(StringImpl* string)
|
| +{
|
| + if (!string->length())
|
| + return StringImpl::empty();
|
|
|
| - HashSet<StringImpl*>& table()
|
| - {
|
| - return m_table;
|
| - }
|
| + StringImpl* result = *m_table.add(string).storedValue;
|
|
|
| -private:
|
| - AtomicStringTable() { }
|
| + if (!result->isAtomic())
|
| + result->setIsAtomic(true);
|
|
|
| - void addStaticStrings()
|
| - {
|
| - const StaticStringsTable& staticStrings = StringImpl::allStaticStrings();
|
| + ASSERT(!string->isStatic() || result->isStatic());
|
| + return result;
|
| +}
|
|
|
| - StaticStringsTable::const_iterator it = staticStrings.begin();
|
| - for (; it != staticStrings.end(); ++it) {
|
| - addStringImpl(it->value);
|
| - }
|
| +AtomicStringTable* AtomicStringTable::create()
|
| +{
|
| + 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 AtomicStringTable::destroy(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 +378,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>
|
|
|