Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1490)

Unified Diff: Source/wtf/text/StringImpl.cpp

Issue 110843004: Replaced HTMLIdentifier with an atomized string factory function (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review fixes Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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");
« Source/core/html/parser/HTMLParserIdioms.cpp ('K') | « Source/wtf/text/StringImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698