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

Unified Diff: third_party/WebKit/Source/wtf/text/StringStatics.cpp

Issue 1363653006: Reserve capacity for static strings HashMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the deduced string length (exclude NULL terminator) Created 5 years, 3 months 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
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/StringStatics.cpp
diff --git a/third_party/WebKit/Source/wtf/text/StringStatics.cpp b/third_party/WebKit/Source/wtf/text/StringStatics.cpp
index 9231216e192fe35d67e40d007828b0a9be01a19a..7a807f6aa21917383201f0813aef5c58581958d2 100644
--- a/third_party/WebKit/Source/wtf/text/StringStatics.cpp
+++ b/third_party/WebKit/Source/wtf/text/StringStatics.cpp
@@ -79,15 +79,23 @@ void AtomicString::init()
new (NotNull, (void*)&emptyAtom) AtomicString("");
}
+template<unsigned charactersCount>
+PassRefPtr<StringImpl> addStaticASCIILiteral(const char (&characters)[charactersCount])
+{
+ unsigned length = charactersCount - 1;
+ unsigned hash = StringHasher::computeHashAndMaskTop8Bits(reinterpret_cast<const LChar*>(characters), length);
+ return adoptRef(StringImpl::createStatic(characters, length, hash));
+}
+
void StringStatics::init()
{
ASSERT(isMainThread());
// FIXME: These should be allocated at compile time.
new (NotNull, (void*)&starAtom) AtomicString("*", AtomicString::ConstructFromLiteral);
- new (NotNull, (void*)&xmlAtom) AtomicString("xml", AtomicString::ConstructFromLiteral);
- new (NotNull, (void*)&xmlnsAtom) AtomicString("xmlns", AtomicString::ConstructFromLiteral);
- new (NotNull, (void*)&xlinkAtom) AtomicString("xlink", AtomicString::ConstructFromLiteral);
+ new (NotNull, (void*)&xmlAtom) AtomicString(addStaticASCIILiteral("xml"));
+ new (NotNull, (void*)&xmlnsAtom) AtomicString(addStaticASCIILiteral("xmlns"));
+ new (NotNull, (void*)&xlinkAtom) AtomicString(addStaticASCIILiteral("xlink"));
new (NotNull, (void*)&xmlnsWithColon) String("xmlns:");
}
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698