Chromium Code Reviews| Index: third_party/WebKit/Source/wtf/text/StringImpl.cpp |
| diff --git a/third_party/WebKit/Source/wtf/text/StringImpl.cpp b/third_party/WebKit/Source/wtf/text/StringImpl.cpp |
| index 303ee9d1ddd1707c356393bd1b2eabdde4c4fce9..9591ba9a05404eae927f140c22f2482dfb14a4af 100644 |
| --- a/third_party/WebKit/Source/wtf/text/StringImpl.cpp |
| +++ b/third_party/WebKit/Source/wtf/text/StringImpl.cpp |
| @@ -343,6 +343,34 @@ void StringImpl::freezeStaticStrings() |
| unsigned StringImpl::m_highestStaticStringLength = 0; |
| +StringImpl* StringImpl::createPreallocatedStatic(void* buffer, unsigned length, unsigned hash) |
| +{ |
| + ASSERT(s_allowCreationOfStaticStrings); |
| + ASSERT(buffer); |
| + ASSERT(length); |
| + |
| + StringImpl* impl = static_cast<StringImpl*>(buffer); |
| + |
| + StaticStringsTable::const_iterator it = staticStrings().find(hash); |
| + if (it != staticStrings().end()) { |
| + ASSERT(!memcmp(reinterpret_cast<LChar*>(impl + 1), it->value + 1, length * sizeof(LChar))); |
| + return it->value; |
|
kouhei (in TOK)
2015/10/21 01:08:17
Are we ever going to reach here? If not, ASSERT?
tzik
2015/10/28 14:33:31
We do actually reach here due to duplicated static
|
| + } |
| + |
| + impl = new (impl) StringImpl(length, hash, StaticString); |
| +#if ENABLE(ASSERT) |
| + impl->assertHashIsCorrect(); |
| +#endif |
| + |
| + ASSERT(isMainThread()); |
| + m_highestStaticStringLength = std::max(m_highestStaticStringLength, length); |
| + staticStrings().add(hash, impl); |
| + WTF_ANNOTATE_BENIGN_RACE(impl, |
| + "Benign race on the reference counter of a static string created by StringImpl::createStatic"); |
|
tkent
2015/10/21 03:19:34
createStatic -> createPreallocatedStatic?
tzik
2015/10/28 14:33:31
Done.
|
| + |
| + return impl; |
| +} |
| + |
| StringImpl* StringImpl::createStatic(const char* string, unsigned length, unsigned hash) |
| { |
| ASSERT(s_allowCreationOfStaticStrings); |