Title: [152337] trunk/Source/WebCore
- Revision
- 152337
- Author
- [email protected]
- Date
- 2013-07-02 22:07:45 -0700 (Tue, 02 Jul 2013)
Log Message
Modernize QualifiedName by wrapping gNameCache in a function and using more early exits
https://bugs.webkit.org/show_bug.cgi?id=118299
Reviewed by Andreas Kling.
Did cleanups.
* dom/QualifiedName.cpp:
(WebCore::qualifiedNameCache): Added to wrap gNameCache.
(WebCore::QualifiedName::QualifiedName):
(WebCore::QualifiedName::QualifiedNameImpl::~QualifiedNameImpl):
(WebCore::QualifiedName::toString): Use early exit and StringBuilder.
(WebCore::QualifiedName::init): Use early exit.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (152336 => 152337)
--- trunk/Source/WebCore/ChangeLog 2013-07-03 03:45:35 UTC (rev 152336)
+++ trunk/Source/WebCore/ChangeLog 2013-07-03 05:07:45 UTC (rev 152337)
@@ -1,3 +1,19 @@
+2013-07-02 Ryosuke Niwa <[email protected]>
+
+ Modernize QualifiedName by wrapping gNameCache in a function and using more early exits
+ https://bugs.webkit.org/show_bug.cgi?id=118299
+
+ Reviewed by Andreas Kling.
+
+ Did cleanups.
+
+ * dom/QualifiedName.cpp:
+ (WebCore::qualifiedNameCache): Added to wrap gNameCache.
+ (WebCore::QualifiedName::QualifiedName):
+ (WebCore::QualifiedName::QualifiedNameImpl::~QualifiedNameImpl):
+ (WebCore::QualifiedName::toString): Use early exit and StringBuilder.
+ (WebCore::QualifiedName::init): Use early exit.
+
2013-07-02 Simon Fraser <[email protected]>
Don't set z-index: 0 on lots of elements with -webkit-overflow-scrolling: touch
Modified: trunk/Source/WebCore/dom/QualifiedName.cpp (152336 => 152337)
--- trunk/Source/WebCore/dom/QualifiedName.cpp 2013-07-03 03:45:35 UTC (rev 152336)
+++ trunk/Source/WebCore/dom/QualifiedName.cpp 2013-07-03 05:07:45 UTC (rev 152337)
@@ -33,6 +33,7 @@
#include <wtf/Assertions.h>
#include <wtf/HashSet.h>
#include <wtf/StaticConstructors.h>
+#include <wtf/text/StringBuilder.h>
#if ENABLE(MATHML)
#include "MathMLNames.h"
@@ -76,14 +77,16 @@
}
};
-static QNameSet* gNameCache;
+static inline QNameSet& qualifiedNameCache()
+{
+ DEFINE_STATIC_LOCAL(QNameSet, nameCache, ());
+ return nameCache;
+}
QualifiedName::QualifiedName(const AtomicString& p, const AtomicString& l, const AtomicString& n)
{
- if (!gNameCache)
- gNameCache = new QNameSet;
QualifiedNameComponents components = { p.impl(), l.impl(), n.isEmpty() ? nullAtom.impl() : n.impl() };
- QNameSet::AddResult addResult = gNameCache->add<QNameComponentsTranslator>(components);
+ QNameSet::AddResult addResult = qualifiedNameCache().add<QNameComponentsTranslator>(components);
m_impl = *addResult.iterator;
if (!addResult.isNewEntry)
m_impl->ref();
@@ -106,19 +109,19 @@
QualifiedName::QualifiedNameImpl::~QualifiedNameImpl()
{
- gNameCache->remove(this);
+ qualifiedNameCache().remove(this);
}
String QualifiedName::toString() const
{
- String local = localName();
- if (hasPrefix()) {
- String result = prefix().string();
- result.append(":");
- result.append(local);
- return result;
- }
- return local;
+ if (!hasPrefix())
+ return localName();
+
+ StringBuilder result;
+ result.append(prefix());
+ result.append(':');
+ result.append(localName());
+ return result.toString();
}
// Global init routines
@@ -126,14 +129,14 @@
void QualifiedName::init()
{
- static bool initialized;
- if (!initialized) {
- // Use placement new to initialize the globals.
-
- AtomicString::init();
- new (NotNull, (void*)&anyName) QualifiedName(nullAtom, starAtom, starAtom);
- initialized = true;
- }
+ static bool initialized = false;
+ if (initialized)
+ return;
+
+ // Use placement new to initialize the globals.
+ AtomicString::init();
+ new (NotNull, (void*)&anyName) QualifiedName(nullAtom, starAtom, starAtom);
+ initialized = true;
}
const QualifiedName& nullQName()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes