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

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

Issue 15622005: Introduce LiteralSet (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Literal, Literal, Literal Created 7 years, 7 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
« no previous file with comments | « no previous file | Source/core/editing/FormatBlockCommand.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 * 18 *
19 */ 19 */
20 20
21 #ifndef QualifiedName_h 21 #ifndef QualifiedName_h
22 #define QualifiedName_h 22 #define QualifiedName_h
23 23
24 #include <wtf/Forward.h> 24 #include "wtf/Forward.h"
25 #include <wtf/HashTraits.h> 25 #include "wtf/HashTraits.h"
26 #include <wtf/RefCounted.h> 26 #include "wtf/LiteralSet.h"
27 #include <wtf/text/AtomicString.h> 27 #include "wtf/RefCounted.h"
28 #include "wtf/text/AtomicString.h"
28 29
29 namespace WebCore { 30 namespace WebCore {
30 31
31 struct QualifiedNameComponents { 32 struct QualifiedNameComponents {
32 StringImpl* m_prefix; 33 StringImpl* m_prefix;
33 StringImpl* m_localName; 34 StringImpl* m_localName;
34 StringImpl* m_namespace; 35 StringImpl* m_namespace;
35 }; 36 };
36 37
37 class QualifiedName { 38 class QualifiedName {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 inline bool operator==(const AtomicString& a, const QualifiedName& q) { return a == q.localName(); } 122 inline bool operator==(const AtomicString& a, const QualifiedName& q) { return a == q.localName(); }
122 inline bool operator!=(const AtomicString& a, const QualifiedName& q) { return a != q.localName(); } 123 inline bool operator!=(const AtomicString& a, const QualifiedName& q) { return a != q.localName(); }
123 inline bool operator==(const QualifiedName& q, const AtomicString& a) { return a == q.localName(); } 124 inline bool operator==(const QualifiedName& q, const AtomicString& a) { return a == q.localName(); }
124 inline bool operator!=(const QualifiedName& q, const AtomicString& a) { return a != q.localName(); } 125 inline bool operator!=(const QualifiedName& q, const AtomicString& a) { return a != q.localName(); }
125 126
126 inline unsigned hashComponents(const QualifiedNameComponents& buf) 127 inline unsigned hashComponents(const QualifiedNameComponents& buf)
127 { 128 {
128 return StringHasher::hashMemory<sizeof(QualifiedNameComponents)>(&buf); 129 return StringHasher::hashMemory<sizeof(QualifiedNameComponents)>(&buf);
129 } 130 }
130 131
132 struct QualifiedNameComparer {
133 static bool lessThan(const QualifiedName* const& a, const QualifiedName* con st& b)
134 {
135 return a->impl() < b->impl();
136 }
137 };
138
139 typedef LiteralSet<const QualifiedName*, QualifiedNameComparer> QualifiedNameLit eralSet;
140
141 struct LocalNameComparer {
142 static bool lessThan(const QualifiedName* const& a, const QualifiedName* con st& b)
143 {
144 return a->localName().impl() < b->localName().impl();
145 }
146 };
147
148 typedef LiteralSet<const QualifiedName*, LocalNameComparer> LocalNameLiteralSet;
149
131 struct QualifiedNameHash { 150 struct QualifiedNameHash {
132 static unsigned hash(const QualifiedName& name) { return hash(name.impl()); } 151 static unsigned hash(const QualifiedName& name) { return hash(name.impl()); }
133 152
134 static unsigned hash(const QualifiedName::QualifiedNameImpl* name) 153 static unsigned hash(const QualifiedName::QualifiedNameImpl* name)
135 { 154 {
136 if (!name->m_existingHash) 155 if (!name->m_existingHash)
137 name->m_existingHash = name->computeHash(); 156 name->m_existingHash = name->computeHash();
138 return name->m_existingHash; 157 return name->m_existingHash;
139 } 158 }
140 159
(...skipping 16 matching lines...) Expand all
157 typedef WebCore::QualifiedNameHash Hash; 176 typedef WebCore::QualifiedNameHash Hash;
158 }; 177 };
159 178
160 template<> struct HashTraits<WebCore::QualifiedName> : SimpleClassHashTraits <WebCore::QualifiedName> { 179 template<> struct HashTraits<WebCore::QualifiedName> : SimpleClassHashTraits <WebCore::QualifiedName> {
161 static const bool emptyValueIsZero = false; 180 static const bool emptyValueIsZero = false;
162 static WebCore::QualifiedName emptyValue() { return WebCore::nullQName() ; } 181 static WebCore::QualifiedName emptyValue() { return WebCore::nullQName() ; }
163 }; 182 };
164 } 183 }
165 184
166 #endif 185 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/editing/FormatBlockCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698