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

Side by Side Diff: Source/core/dom/QualifiedName.h

Issue 311803003: [oilpan]: Avoid refcounting QualifiedName's nullQName when tracing. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: New QName hash trait Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 , m_prefix(prefix) 60 , m_prefix(prefix)
61 , m_localName(localName) 61 , m_localName(localName)
62 , m_namespace(namespaceURI) 62 , m_namespace(namespaceURI)
63 { 63 {
64 ASSERT(!namespaceURI.isEmpty() || namespaceURI.isNull()); 64 ASSERT(!namespaceURI.isEmpty() || namespaceURI.isNull());
65 } 65 }
66 }; 66 };
67 67
68 QualifiedName(const AtomicString& prefix, const AtomicString& localName, con st AtomicString& namespaceURI); 68 QualifiedName(const AtomicString& prefix, const AtomicString& localName, con st AtomicString& namespaceURI);
69 ~QualifiedName(); 69 ~QualifiedName();
70 #ifdef QNAME_DEFAULT_CONSTRUCTOR 70 QualifiedName() : m_impl(nullptr) { }
71 QualifiedName() { }
72 #endif
73 71
74 QualifiedName(const QualifiedName& other) : m_impl(other.m_impl) { } 72 QualifiedName(const QualifiedName& other) : m_impl(other.m_impl) { }
75 const QualifiedName& operator=(const QualifiedName& other) { m_impl = other. m_impl; return *this; } 73 const QualifiedName& operator=(const QualifiedName& other) { m_impl = other. m_impl; return *this; }
76 74
77 // Hash table deleted values, which are only constructed and never copied or destroyed. 75 // Hash table deleted values, which are only constructed and never copied or destroyed.
78 QualifiedName(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeleted Value) { } 76 QualifiedName(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeleted Value) { }
79 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue (); } 77 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue (); }
80 78
81 bool operator==(const QualifiedName& other) const { return m_impl == other.m _impl; } 79 bool operator==(const QualifiedName& other) const { return m_impl == other.m _impl; }
82 bool operator!=(const QualifiedName& other) const { return !(*this == other) ; } 80 bool operator!=(const QualifiedName& other) const { return !(*this == other) ; }
83 81
84 bool matches(const QualifiedName& other) const { return m_impl == other.m_im pl || (localName() == other.localName() && namespaceURI() == other.namespaceURI( )); } 82 bool matches(const QualifiedName& other) const { return m_impl == other.m_im pl || (localName() == other.localName() && namespaceURI() == other.namespaceURI( )); }
85 83
86 bool matchesPossiblyIgnoringCase(const QualifiedName& other, bool shouldIgno reCase) const { return m_impl == other.m_impl || (equalPossiblyIgnoringCase(loca lName(), other.localName(), shouldIgnoreCase) && namespaceURI() == other.namespa ceURI()); } 84 bool matchesPossiblyIgnoringCase(const QualifiedName& other, bool shouldIgno reCase) const { return m_impl == other.m_impl || (equalPossiblyIgnoringCase(loca lName(), other.localName(), shouldIgnoreCase) && namespaceURI() == other.namespa ceURI()); }
87 85
88 bool hasPrefix() const { return m_impl->m_prefix != nullAtom; } 86 bool hasPrefix() const { return m_impl ? (m_impl->m_prefix != nullAtom) : fa lse; }
esprehn 2014/06/05 00:58:44 Don't use a ternary, use &&. return m_impl && m_i
89 void setPrefix(const AtomicString& prefix) { *this = QualifiedName(prefix, l ocalName(), namespaceURI()); } 87 void setPrefix(const AtomicString& prefix) { *this = QualifiedName(prefix, l ocalName(), namespaceURI()); }
90 88
91 const AtomicString& prefix() const { return m_impl->m_prefix; } 89 const AtomicString& prefix() const { return m_impl ? m_impl->m_prefix : null Atom; }
92 const AtomicString& localName() const { return m_impl->m_localName; } 90 const AtomicString& localName() const { return m_impl ? m_impl->m_localName : nullAtom; }
93 const AtomicString& namespaceURI() const { return m_impl->m_namespace; } 91 const AtomicString& namespaceURI() const { return m_impl ? m_impl->m_namespa ce : nullAtom; }
esprehn 2014/06/05 00:58:44 This code can all be really hot, we call into it a
94 92
95 // Uppercased localName, cached for efficiency 93 // Uppercased localName, cached for efficiency
96 const AtomicString& localNameUpper() const; 94 const AtomicString& localNameUpper() const;
97 95
98 String toString() const; 96 String toString() const;
99 97
100 QualifiedNameImpl* impl() const { return m_impl.get(); } 98 QualifiedNameImpl* impl() const { return m_impl ? m_impl.get() : 0; }
esprehn 2014/06/05 00:58:44 The ternary is not needed here.
99 bool isNull() const { return !m_impl; }
101 100
102 // Init routine for globals 101 // Init routine for globals
103 static void init(); 102 static void init();
104 103
105 private: 104 private:
106 RefPtr<QualifiedNameImpl> m_impl; 105 RefPtr<QualifiedNameImpl> m_impl;
107 }; 106 };
108 107
109 #ifndef WEBCORE_QUALIFIEDNAME_HIDE_GLOBALS 108 #ifndef WEBCORE_QUALIFIEDNAME_HIDE_GLOBALS
110 extern const QualifiedName anyName; 109 extern const QualifiedName anyName;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 145
147 namespace WTF { 146 namespace WTF {
148 147
149 template<typename T> struct DefaultHash; 148 template<typename T> struct DefaultHash;
150 149
151 template<> struct DefaultHash<WebCore::QualifiedName> { 150 template<> struct DefaultHash<WebCore::QualifiedName> {
152 typedef WebCore::QualifiedNameHash Hash; 151 typedef WebCore::QualifiedNameHash Hash;
153 }; 152 };
154 153
155 template<> struct HashTraits<WebCore::QualifiedName> : SimpleClassHashTraits <WebCore::QualifiedName> { 154 template<> struct HashTraits<WebCore::QualifiedName> : SimpleClassHashTraits <WebCore::QualifiedName> {
156 static const bool emptyValueIsZero = false; 155 static const bool hasIsEmptyValueFunction = true;
157 static WebCore::QualifiedName emptyValue() { return WebCore::nullQName() ; } 156 static bool isEmptyValue(const WebCore::QualifiedName& q) { return q.isN ull(); }
158 }; 157 };
159 } 158 }
160 159
161 #endif 160 #endif
OLDNEW
« no previous file with comments | « Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl ('k') | Source/core/dom/QualifiedName.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698