| 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 56b81dabfe350d8e03258d5204c07c00f4dc51b7..bc5ad1352a8c736a567fe704e35f23134806a07d 100644
|
| --- a/third_party/WebKit/Source/wtf/text/StringImpl.cpp
|
| +++ b/third_party/WebKit/Source/wtf/text/StringImpl.cpp
|
| @@ -341,32 +341,24 @@ void StringImpl::freezeStaticStrings()
|
| #endif
|
| }
|
|
|
| +
|
| unsigned StringImpl::m_highestStaticStringLength = 0;
|
|
|
| -StringImpl* StringImpl::createStatic(const char* string, unsigned length, unsigned hash)
|
| +StringImpl* StringImpl::createPreallocatedStatic(void* buffer, unsigned length, unsigned hash)
|
| {
|
| ASSERT(s_allowCreationOfStaticStrings);
|
| - ASSERT(string);
|
| + ASSERT(buffer);
|
| ASSERT(length);
|
|
|
| + StringImpl* impl = static_cast<StringImpl*>(buffer);
|
| +
|
| StaticStringsTable::const_iterator it = staticStrings().find(hash);
|
| if (it != staticStrings().end()) {
|
| - ASSERT(!memcmp(string, it->value + 1, length * sizeof(LChar)));
|
| + ASSERT(!memcmp(reinterpret_cast<LChar*>(impl + 1), it->value + 1, length * sizeof(LChar)));
|
| return it->value;
|
| }
|
|
|
| - // Allocate a single buffer large enough to contain the StringImpl
|
| - // struct as well as the data which it contains. This removes one
|
| - // heap allocation from this call.
|
| - RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof(StringImpl)) / sizeof(LChar)));
|
| - size_t size = sizeof(StringImpl) + length * sizeof(LChar);
|
| -
|
| - WTF_ANNOTATE_SCOPED_MEMORY_LEAK;
|
| - StringImpl* impl = static_cast<StringImpl*>(Partitions::bufferMalloc(size));
|
| -
|
| - LChar* data = reinterpret_cast<LChar*>(impl + 1);
|
| impl = new (impl) StringImpl(length, hash, StaticString);
|
| - memcpy(data, string, length * sizeof(LChar));
|
| #if ENABLE(ASSERT)
|
| impl->assertHashIsCorrect();
|
| #endif
|
| @@ -375,7 +367,7 @@ StringImpl* StringImpl::createStatic(const char* string, unsigned length, unsign
|
| 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");
|
| + "Benign race on the reference counter of a static string created by StringImpl::createPreallocatedStatic");
|
|
|
| return impl;
|
| }
|
|
|