Chromium Code Reviews| Index: Source/wtf/text/StringImpl.cpp |
| diff --git a/Source/wtf/text/StringImpl.cpp b/Source/wtf/text/StringImpl.cpp |
| index 090f02534446d24aa92ef17a798665a8646efde7..9ce99e893870274e72c70c2fe66bd0dfe8c50cb8 100644 |
| --- a/Source/wtf/text/StringImpl.cpp |
| +++ b/Source/wtf/text/StringImpl.cpp |
| @@ -358,9 +358,9 @@ PassRefPtr<StringImpl> StringImpl::reallocate(PassRefPtr<StringImpl> originalStr |
| return adoptRef(new (string) StringImpl(length)); |
| } |
| -static Vector<StringImpl*>& staticStrings() |
| +static StaticStringsTable& staticStrings() |
| { |
| - DEFINE_STATIC_LOCAL(Vector<StringImpl*>, staticStrings, ()); |
| + DEFINE_STATIC_LOCAL(StaticStringsTable, staticStrings, ()); |
| return staticStrings; |
| } |
| @@ -368,7 +368,7 @@ static Vector<StringImpl*>& staticStrings() |
| static bool s_allowCreationOfStaticStrings = true; |
| #endif |
| -const Vector<StringImpl*>& StringImpl::allStaticStrings() |
| +const StaticStringsTable& StringImpl::allStaticStrings() |
| { |
| return staticStrings(); |
| } |
| @@ -380,10 +380,10 @@ void StringImpl::freezeStaticStrings() |
| #ifndef NDEBUG |
| s_allowCreationOfStaticStrings = false; |
| #endif |
| - |
| - staticStrings().shrinkToFit(); |
| } |
| +unsigned StringImpl::m_highestStaticStringLength = 0; |
| + |
| StringImpl* StringImpl::createStatic(const char* string, unsigned length, unsigned hash) |
| { |
| ASSERT(s_allowCreationOfStaticStrings); |
| @@ -406,7 +406,8 @@ StringImpl* StringImpl::createStatic(const char* string, unsigned length, unsign |
| #endif |
| ASSERT(isMainThread()); |
| - staticStrings().append(impl); |
| + m_highestStaticStringLength = std::max(m_highestStaticStringLength, length); |
| + staticStrings().add(hash, impl); |
|
abarth-chromium
2013/12/10 04:48:23
Can you ASSERT that this hash isn't already in the
oystein (OOO til 10th of July)
2013/12/10 18:42:27
There were actually some duplicates here (SVGNames
|
| WTF_ANNOTATE_BENIGN_RACE(impl, |
| "Benign race on the reference counter of a static string created by StringImpl::createStatic"); |