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

Unified Diff: third_party/WebKit/Source/core/dom/QualifiedName.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
Index: third_party/WebKit/Source/core/dom/QualifiedName.cpp
diff --git a/third_party/WebKit/Source/core/dom/QualifiedName.cpp b/third_party/WebKit/Source/core/dom/QualifiedName.cpp
index 32a0849c77ed72343ab1eb36b8ba0894db1d3cbf..c709861fa9202d369994d87ccd60d883c1d48791 100644
--- a/third_party/WebKit/Source/core/dom/QualifiedName.cpp
+++ b/third_party/WebKit/Source/core/dom/QualifiedName.cpp
@@ -41,18 +41,7 @@ struct SameSizeAsQualifiedNameImpl : public RefCounted<SameSizeAsQualifiedNameIm
static_assert(sizeof(QualifiedName::QualifiedNameImpl) == sizeof(SameSizeAsQualifiedNameImpl), "QualifiedNameImpl should stay small");
-static const int staticQualifiedNamesCount = HTMLNames::HTMLTagsCount + HTMLNames::HTMLAttrsCount
- + MathMLNames::MathMLTagsCount + MathMLNames::MathMLAttrsCount
- + SVGNames::SVGTagsCount + SVGNames::SVGAttrsCount
- + XLinkNames::XLinkAttrsCount
- + XMLNSNames::XMLNSAttrsCount
- + XMLNames::XMLAttrsCount;
-
-struct QualifiedNameHashTraits : public HashTraits<QualifiedName::QualifiedNameImpl*> {
- static const unsigned minimumTableSize = WTF::HashTableCapacityForSize<staticQualifiedNamesCount>::value;
-};
-
-typedef HashSet<QualifiedName::QualifiedNameImpl*, QualifiedNameHash, QualifiedNameHashTraits> QualifiedNameCache;
+using QualifiedNameCache = HashSet<QualifiedName::QualifiedNameImpl*, QualifiedNameHash>;
static QualifiedNameCache& qualifiedNameCache()
{
@@ -115,9 +104,10 @@ String QualifiedName::toString() const
DEFINE_GLOBAL(QualifiedName, anyName, nullAtom, starAtom, starAtom)
DEFINE_GLOBAL(QualifiedName, nullName, nullAtom, nullAtom, nullAtom)
-void QualifiedName::init()
+void QualifiedName::initAndReserveCapacityForSize(unsigned size)
{
ASSERT(starAtom.impl());
+ qualifiedNameCache().reserveCapacityForSize(size + 2 /*starAtom and nullAtom */);
new ((void*)&anyName) QualifiedName(nullAtom, starAtom, starAtom, true );
new ((void*)&nullName) QualifiedName(nullAtom, nullAtom, nullAtom, true );
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/QualifiedName.h ('k') | third_party/WebKit/Source/modules/InitModules.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698