Changeset 152337 in webkit
- Timestamp:
- Jul 2, 2013 10:07:45 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r152335 r152337 1 2013-07-02 Ryosuke Niwa <rniwa@webkit.org> 2 3 Modernize QualifiedName by wrapping gNameCache in a function and using more early exits 4 https://bugs.webkit.org/show_bug.cgi?id=118299 5 6 Reviewed by Andreas Kling. 7 8 Did cleanups. 9 10 * dom/QualifiedName.cpp: 11 (WebCore::qualifiedNameCache): Added to wrap gNameCache. 12 (WebCore::QualifiedName::QualifiedName): 13 (WebCore::QualifiedName::QualifiedNameImpl::~QualifiedNameImpl): 14 (WebCore::QualifiedName::toString): Use early exit and StringBuilder. 15 (WebCore::QualifiedName::init): Use early exit. 16 1 17 2013-07-02 Simon Fraser <simon.fraser@apple.com> 2 18 -
trunk/Source/WebCore/dom/QualifiedName.cpp
r151800 r152337 34 34 #include <wtf/HashSet.h> 35 35 #include <wtf/StaticConstructors.h> 36 #include <wtf/text/StringBuilder.h> 36 37 37 38 #if ENABLE(MATHML) … … 77 78 }; 78 79 79 static QNameSet* gNameCache; 80 static inline QNameSet& qualifiedNameCache() 81 { 82 DEFINE_STATIC_LOCAL(QNameSet, nameCache, ()); 83 return nameCache; 84 } 80 85 81 86 QualifiedName::QualifiedName(const AtomicString& p, const AtomicString& l, const AtomicString& n) 82 87 { 83 if (!gNameCache)84 gNameCache = new QNameSet;85 88 QualifiedNameComponents components = { p.impl(), l.impl(), n.isEmpty() ? nullAtom.impl() : n.impl() }; 86 QNameSet::AddResult addResult = gNameCache->add<QNameComponentsTranslator>(components);89 QNameSet::AddResult addResult = qualifiedNameCache().add<QNameComponentsTranslator>(components); 87 90 m_impl = *addResult.iterator; 88 91 if (!addResult.isNewEntry) … … 107 110 QualifiedName::QualifiedNameImpl::~QualifiedNameImpl() 108 111 { 109 gNameCache->remove(this);112 qualifiedNameCache().remove(this); 110 113 } 111 114 112 115 String QualifiedName::toString() const 113 116 { 114 String local = localName();115 if (hasPrefix()) {116 String result = prefix().string(); 117 result.append(":");118 result.append(local);119 return result;120 }121 return local;117 if (!hasPrefix()) 118 return localName(); 119 120 StringBuilder result; 121 result.append(prefix()); 122 result.append(':'); 123 result.append(localName()); 124 return result.toString(); 122 125 } 123 126 … … 127 130 void QualifiedName::init() 128 131 { 129 static bool initialized ;130 if ( !initialized) {131 // Use placement new to initialize the globals.132 133 AtomicString::init();134 new (NotNull, (void*)&anyName) QualifiedName(nullAtom, starAtom, starAtom);135 initialized = true;136 }132 static bool initialized = false; 133 if (initialized) 134 return; 135 136 // Use placement new to initialize the globals. 137 AtomicString::init(); 138 new (NotNull, (void*)&anyName) QualifiedName(nullAtom, starAtom, starAtom); 139 initialized = true; 137 140 } 138 141
Note: See TracChangeset
for help on using the changeset viewer.