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

Side by Side Diff: third_party/WebKit/Source/wtf/text/AtomicString.h

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2008 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 13 matching lines...) Expand all
24 #include "wtf/HashTableDeletedValueType.h" 24 #include "wtf/HashTableDeletedValueType.h"
25 #include "wtf/WTFExport.h" 25 #include "wtf/WTFExport.h"
26 #include "wtf/text/CString.h" 26 #include "wtf/text/CString.h"
27 #include "wtf/text/WTFString.h" 27 #include "wtf/text/WTFString.h"
28 28
29 namespace WTF { 29 namespace WTF {
30 30
31 struct AtomicStringHash; 31 struct AtomicStringHash;
32 32
33 class WTF_EXPORT AtomicString { 33 class WTF_EXPORT AtomicString {
34 public: 34 public:
35 static void init(); 35 static void init();
36 static void reserveTableCapacity(size_t); 36 static void reserveTableCapacity(size_t);
37 37
38 AtomicString() { } 38 AtomicString() {}
39 AtomicString(const LChar* s) : m_string(add(s)) { } 39 AtomicString(const LChar* s)
40 AtomicString(const char* s) : m_string(add(s)) { } 40 : m_string(add(s)) {}
41 AtomicString(const LChar* s, unsigned length) : m_string(add(s, length)) { } 41 AtomicString(const char* s)
42 AtomicString(const UChar* s, unsigned length) : m_string(add(s, length)) { } 42 : m_string(add(s)) {}
43 AtomicString(const UChar* s, unsigned length, unsigned existingHash) : m_str ing(add(s, length, existingHash)) { } 43 AtomicString(const LChar* s, unsigned length)
44 AtomicString(const UChar* s) : m_string(add(s)) { } 44 : m_string(add(s, length)) {}
45 45 AtomicString(const UChar* s, unsigned length)
46 template<size_t inlineCapacity> 46 : m_string(add(s, length)) {}
47 explicit AtomicString(const Vector<UChar, inlineCapacity>& characters) 47 AtomicString(const UChar* s, unsigned length, unsigned existingHash)
48 : m_string(add(characters.data(), characters.size())) 48 : m_string(add(s, length, existingHash)) {}
49 { 49 AtomicString(const UChar* s)
50 } 50 : m_string(add(s)) {}
51 51
52 // Constructing an AtomicString from a String / StringImpl can be expensive if 52 template <size_t inlineCapacity>
53 // the StringImpl is not already atomic. 53 explicit AtomicString(const Vector<UChar, inlineCapacity>& characters)
54 explicit AtomicString(StringImpl* impl) : m_string(add(impl)) { } 54 : m_string(add(characters.data(), characters.size())) {
55 explicit AtomicString(const String& s) : m_string(add(s.impl())) { } 55 }
56 56
57 AtomicString(StringImpl* baseString, unsigned start, unsigned length) : m_st ring(add(baseString, start, length)) { } 57 // Constructing an AtomicString from a String / StringImpl can be expensive if
58 58 // the StringImpl is not already atomic.
59 enum ConstructFromLiteralTag { ConstructFromLiteral }; 59 explicit AtomicString(StringImpl* impl)
60 AtomicString(const char* characters, unsigned length, ConstructFromLiteralTa g) 60 : m_string(add(impl)) {}
61 : m_string(addFromLiteralData(characters, length)) 61 explicit AtomicString(const String& s)
62 { 62 : m_string(add(s.impl())) {}
63 } 63
64 64 AtomicString(StringImpl* baseString, unsigned start, unsigned length)
65 template<unsigned charactersCount> 65 : m_string(add(baseString, start, length)) {}
66 ALWAYS_INLINE AtomicString(const char (&characters)[charactersCount], Constr uctFromLiteralTag) 66
67 : m_string(addFromLiteralData(characters, charactersCount - 1)) 67 enum ConstructFromLiteralTag { ConstructFromLiteral };
68 { 68 AtomicString(const char* characters, unsigned length, ConstructFromLiteralTag)
69 static_assert(charactersCount > 1, "AtomicString FromLiteralData should not be empty"); 69 : m_string(addFromLiteralData(characters, length)) {
70 static_assert((charactersCount - 1 <= ((unsigned(~0) - sizeof(StringImpl )) / sizeof(LChar))), "AtomicString FromLiteralData cannot overflow"); 70 }
71 } 71
72 72 template <unsigned charactersCount>
73 // Hash table deleted values, which are only constructed and never copied or destroyed. 73 ALWAYS_INLINE AtomicString(const char(&characters)[charactersCount], Construct FromLiteralTag)
74 AtomicString(WTF::HashTableDeletedValueType) : m_string(WTF::HashTableDelete dValue) { } 74 : m_string(addFromLiteralData(characters, charactersCount - 1)) {
75 bool isHashTableDeletedValue() const { return m_string.isHashTableDeletedVal ue(); } 75 static_assert(charactersCount > 1, "AtomicString FromLiteralData should not be empty");
76 76 static_assert((charactersCount - 1 <= ((unsigned(~0) - sizeof(StringImpl)) / sizeof(LChar))), "AtomicString FromLiteralData cannot overflow");
77 static StringImpl* find(const StringImpl*); 77 }
78 78
79 operator const String&() const { return m_string; } 79 // Hash table deleted values, which are only constructed and never copied or d estroyed.
80 const String& string() const { return m_string; } 80 AtomicString(WTF::HashTableDeletedValueType)
81 81 : m_string(WTF::HashTableDeletedValue) {}
82 StringImpl* impl() const { return m_string.impl(); } 82 bool isHashTableDeletedValue() const { return m_string.isHashTableDeletedValue (); }
83 83
84 bool is8Bit() const { return m_string.is8Bit(); } 84 static StringImpl* find(const StringImpl*);
85 const LChar* characters8() const { return m_string.characters8(); } 85
86 const UChar* characters16() const { return m_string.characters16(); } 86 operator const String&() const { return m_string; }
87 unsigned length() const { return m_string.length(); } 87 const String& string() const { return m_string; }
88 88
89 UChar operator[](unsigned i) const { return m_string[i]; } 89 StringImpl* impl() const { return m_string.impl(); }
90 90
91 bool contains(UChar c) const { return m_string.contains(c); } 91 bool is8Bit() const { return m_string.is8Bit(); }
92 bool contains(const LChar* s, TextCaseSensitivity caseSensitivity = TextCase Sensitive) const 92 const LChar* characters8() const { return m_string.characters8(); }
93 { return m_string.contains(s, caseSensitivity); } 93 const UChar* characters16() const { return m_string.characters16(); }
94 bool contains(const String& s, TextCaseSensitivity caseSensitivity = TextCas eSensitive) const 94 unsigned length() const { return m_string.length(); }
95 { return m_string.contains(s, caseSensitivity); } 95
96 96 UChar operator[](unsigned i) const { return m_string[i]; }
97 size_t find(UChar c, size_t start = 0) const { return m_string.find(c, start ); } 97
98 size_t find(const LChar* s, size_t start = 0, TextCaseSensitivity caseSensit ivity = TextCaseSensitive) const 98 bool contains(UChar c) const { return m_string.contains(c); }
99 { return m_string.find(s, start, caseSensitivity); } 99 bool contains(const LChar* s, TextCaseSensitivity caseSensitivity = TextCaseSe nsitive) const { return m_string.contains(s, caseSensitivity); }
100 size_t find(const String& s, size_t start = 0, TextCaseSensitivity caseSensi tivity = TextCaseSensitive) const 100 bool contains(const String& s, TextCaseSensitivity caseSensitivity = TextCaseS ensitive) const { return m_string.contains(s, caseSensitivity); }
101 { return m_string.find(s, start, caseSensitivity); } 101
102 102 size_t find(UChar c, size_t start = 0) const { return m_string.find(c, start); }
103 bool startsWith(const String& s, TextCaseSensitivity caseSensitivity = TextC aseSensitive) const 103 size_t find(const LChar* s, size_t start = 0, TextCaseSensitivity caseSensitiv ity = TextCaseSensitive) const { return m_string.find(s, start, caseSensitivity) ; }
104 { return m_string.startsWith(s, caseSensitivity); } 104 size_t find(const String& s, size_t start = 0, TextCaseSensitivity caseSensiti vity = TextCaseSensitive) const { return m_string.find(s, start, caseSensitivity ); }
105 bool startsWith(UChar character) const 105
106 { return m_string.startsWith(character); } 106 bool startsWith(const String& s, TextCaseSensitivity caseSensitivity = TextCas eSensitive) const { return m_string.startsWith(s, caseSensitivity); }
107 template<unsigned matchLength> 107 bool startsWith(UChar character) const { return m_string.startsWith(character) ; }
108 bool startsWith(const char (&prefix)[matchLength], TextCaseSensitivity caseS ensitivity = TextCaseSensitive) const 108 template <unsigned matchLength>
109 { return m_string.startsWith<matchLength>(prefix, caseSensitivity); } 109 bool startsWith(const char(&prefix)[matchLength], TextCaseSensitivity caseSens itivity = TextCaseSensitive) const { return m_string.startsWith<matchLength>(pre fix, caseSensitivity); }
110 110
111 bool endsWith(const String& s, TextCaseSensitivity caseSensitivity = TextCas eSensitive) const 111 bool endsWith(const String& s, TextCaseSensitivity caseSensitivity = TextCaseS ensitive) const { return m_string.endsWith(s, caseSensitivity); }
112 { return m_string.endsWith(s, caseSensitivity); } 112 bool endsWith(UChar character) const { return m_string.endsWith(character); }
113 bool endsWith(UChar character) const 113 template <unsigned matchLength>
114 { return m_string.endsWith(character); } 114 bool endsWith(const char(&prefix)[matchLength], TextCaseSensitivity caseSensit ivity = TextCaseSensitive) const { return m_string.endsWith<matchLength>(prefix, caseSensitivity); }
115 template<unsigned matchLength> 115
116 bool endsWith(const char (&prefix)[matchLength], TextCaseSensitivity caseSen sitivity = TextCaseSensitive) const 116 AtomicString lower() const;
117 { return m_string.endsWith<matchLength>(prefix, caseSensitivity); } 117 AtomicString upper() const { return AtomicString(impl()->upper()); }
118 118
119 AtomicString lower() const; 119 int toInt(bool* ok = 0) const { return m_string.toInt(ok); }
120 AtomicString upper() const { return AtomicString(impl()->upper()); } 120 double toDouble(bool* ok = 0) const { return m_string.toDouble(ok); }
121 121 float toFloat(bool* ok = 0) const { return m_string.toFloat(ok); }
122 int toInt(bool* ok = 0) const { return m_string.toInt(ok); } 122
123 double toDouble(bool* ok = 0) const { return m_string.toDouble(ok); } 123 static AtomicString number(int);
124 float toFloat(bool* ok = 0) const { return m_string.toFloat(ok); } 124 static AtomicString number(unsigned);
125 125 static AtomicString number(long);
126 static AtomicString number(int); 126 static AtomicString number(unsigned long);
127 static AtomicString number(unsigned); 127 static AtomicString number(long long);
128 static AtomicString number(long); 128 static AtomicString number(unsigned long long);
129 static AtomicString number(unsigned long); 129
130 static AtomicString number(long long); 130 static AtomicString number(double, unsigned precision = 6, TrailingZerosTrunca tingPolicy = TruncateTrailingZeros);
131 static AtomicString number(unsigned long long); 131
132 132 bool isNull() const { return m_string.isNull(); }
133 static AtomicString number(double, unsigned precision = 6, TrailingZerosTrun catingPolicy = TruncateTrailingZeros); 133 bool isEmpty() const { return m_string.isEmpty(); }
134 134
135 bool isNull() const { return m_string.isNull(); } 135 static void remove(StringImpl*);
136 bool isEmpty() const { return m_string.isEmpty(); }
137
138 static void remove(StringImpl*);
139 136
140 #ifdef __OBJC__ 137 #ifdef __OBJC__
141 AtomicString(NSString* s) : m_string(add((CFStringRef)s)) { } 138 AtomicString(NSString* s)
142 operator NSString*() const { return m_string; } 139 : m_string(add((CFStringRef)s)) {}
140 operator NSString*() const { return m_string; }
143 #endif 141 #endif
144 // AtomicString::fromUTF8 will return a null string if 142 // AtomicString::fromUTF8 will return a null string if
145 // the input data contains invalid UTF-8 sequences. 143 // the input data contains invalid UTF-8 sequences.
146 static AtomicString fromUTF8(const char*, size_t); 144 static AtomicString fromUTF8(const char*, size_t);
147 static AtomicString fromUTF8(const char*); 145 static AtomicString fromUTF8(const char*);
148 146
149 CString ascii() const { return m_string.ascii(); } 147 CString ascii() const { return m_string.ascii(); }
150 CString latin1() const { return m_string.latin1(); } 148 CString latin1() const { return m_string.latin1(); }
151 CString utf8(UTF8ConversionMode mode = LenientUTF8Conversion) const { return m_string.utf8(mode); } 149 CString utf8(UTF8ConversionMode mode = LenientUTF8Conversion) const { return m _string.utf8(mode); }
152 150
153 #ifndef NDEBUG 151 #ifndef NDEBUG
154 void show() const; 152 void show() const;
155 #endif 153 #endif
156 154
157 private: 155 private:
158 String m_string; 156 String m_string;
159 157
160 static PassRefPtr<StringImpl> add(const LChar*); 158 static PassRefPtr<StringImpl> add(const LChar*);
161 ALWAYS_INLINE static PassRefPtr<StringImpl> add(const char* s) { return add( reinterpret_cast<const LChar*>(s)); } 159 ALWAYS_INLINE static PassRefPtr<StringImpl> add(const char* s) { return add(re interpret_cast<const LChar*>(s)); }
162 static PassRefPtr<StringImpl> add(const LChar*, unsigned length); 160 static PassRefPtr<StringImpl> add(const LChar*, unsigned length);
163 static PassRefPtr<StringImpl> add(const UChar*, unsigned length); 161 static PassRefPtr<StringImpl> add(const UChar*, unsigned length);
164 ALWAYS_INLINE static PassRefPtr<StringImpl> add(const char* s, unsigned leng th) { return add(reinterpret_cast<const LChar*>(s), length); } 162 ALWAYS_INLINE static PassRefPtr<StringImpl> add(const char* s, unsigned length ) { return add(reinterpret_cast<const LChar*>(s), length); }
165 static PassRefPtr<StringImpl> add(const UChar*, unsigned length, unsigned ex istingHash); 163 static PassRefPtr<StringImpl> add(const UChar*, unsigned length, unsigned exis tingHash);
166 static PassRefPtr<StringImpl> add(const UChar*); 164 static PassRefPtr<StringImpl> add(const UChar*);
167 static PassRefPtr<StringImpl> add(StringImpl*, unsigned offset, unsigned len gth); 165 static PassRefPtr<StringImpl> add(StringImpl*, unsigned offset, unsigned lengt h);
168 ALWAYS_INLINE static PassRefPtr<StringImpl> add(StringImpl* r) 166 ALWAYS_INLINE static PassRefPtr<StringImpl> add(StringImpl* r) {
169 { 167 if (!r || r->isAtomic())
170 if (!r || r->isAtomic()) 168 return r;
171 return r; 169 return addSlowCase(r);
172 return addSlowCase(r); 170 }
173 } 171 static PassRefPtr<StringImpl> addFromLiteralData(const char* characters, unsig ned length);
174 static PassRefPtr<StringImpl> addFromLiteralData(const char* characters, uns igned length); 172 static PassRefPtr<StringImpl> addSlowCase(StringImpl*);
175 static PassRefPtr<StringImpl> addSlowCase(StringImpl*);
176 #if OS(MACOSX) 173 #if OS(MACOSX)
177 static PassRefPtr<StringImpl> add(CFStringRef); 174 static PassRefPtr<StringImpl> add(CFStringRef);
178 #endif 175 #endif
179 176
180 static AtomicString fromUTF8Internal(const char*, const char*); 177 static AtomicString fromUTF8Internal(const char*, const char*);
181 }; 178 };
182 179
183 inline bool operator==(const AtomicString& a, const AtomicString& b) { return a. impl() == b.impl(); } 180 inline bool operator==(const AtomicString& a, const AtomicString& b) {
181 return a.impl() == b.impl();
182 }
184 WTF_EXPORT bool operator==(const AtomicString&, const LChar*); 183 WTF_EXPORT bool operator==(const AtomicString&, const LChar*);
185 inline bool operator==(const AtomicString& a, const char* b) { return WTF::equal (a.impl(), reinterpret_cast<const LChar*>(b)); } 184 inline bool operator==(const AtomicString& a, const char* b) {
186 inline bool operator==(const AtomicString& a, const Vector<UChar>& b) { return a .impl() && equal(a.impl(), b.data(), b.size()); } 185 return WTF::equal(a.impl(), reinterpret_cast<const LChar*>(b));
187 inline bool operator==(const AtomicString& a, const String& b) { return equal(a. impl(), b.impl()); } 186 }
188 inline bool operator==(const LChar* a, const AtomicString& b) { return b == a; } 187 inline bool operator==(const AtomicString& a, const Vector<UChar>& b) {
189 inline bool operator==(const char* a, const AtomicString& b) { return b == a; } 188 return a.impl() && equal(a.impl(), b.data(), b.size());
190 inline bool operator==(const String& a, const AtomicString& b) { return equal(a. impl(), b.impl()); } 189 }
191 inline bool operator==(const Vector<UChar>& a, const AtomicString& b) { return b == a; } 190 inline bool operator==(const AtomicString& a, const String& b) {
192 191 return equal(a.impl(), b.impl());
193 inline bool operator!=(const AtomicString& a, const AtomicString& b) { return a. impl() != b.impl(); } 192 }
194 inline bool operator!=(const AtomicString& a, const LChar* b) { return !(a == b) ; } 193 inline bool operator==(const LChar* a, const AtomicString& b) {
195 inline bool operator!=(const AtomicString& a, const char* b) { return !(a == b); } 194 return b == a;
196 inline bool operator!=(const AtomicString& a, const String& b) { return !equal(a .impl(), b.impl()); } 195 }
197 inline bool operator!=(const AtomicString& a, const Vector<UChar>& b) { return ! (a == b); } 196 inline bool operator==(const char* a, const AtomicString& b) {
198 inline bool operator!=(const LChar* a, const AtomicString& b) { return !(b == a) ; } 197 return b == a;
199 inline bool operator!=(const char* a, const AtomicString& b) { return !(b == a); } 198 }
200 inline bool operator!=(const String& a, const AtomicString& b) { return !equal(a .impl(), b.impl()); } 199 inline bool operator==(const String& a, const AtomicString& b) {
201 inline bool operator!=(const Vector<UChar>& a, const AtomicString& b) { return ! (a == b); } 200 return equal(a.impl(), b.impl());
202 201 }
203 inline bool equalIgnoringCase(const AtomicString& a, const AtomicString& b) { re turn equalIgnoringCase(a.impl(), b.impl()); } 202 inline bool operator==(const Vector<UChar>& a, const AtomicString& b) {
204 inline bool equalIgnoringCase(const AtomicString& a, const LChar* b) { return eq ualIgnoringCase(a.impl(), b); } 203 return b == a;
205 inline bool equalIgnoringCase(const AtomicString& a, const char* b) { return equ alIgnoringCase(a.impl(), reinterpret_cast<const LChar*>(b)); } 204 }
206 inline bool equalIgnoringCase(const AtomicString& a, const String& b) { return e qualIgnoringCase(a.impl(), b.impl()); } 205
207 inline bool equalIgnoringCase(const LChar* a, const AtomicString& b) { return eq ualIgnoringCase(a, b.impl()); } 206 inline bool operator!=(const AtomicString& a, const AtomicString& b) {
208 inline bool equalIgnoringCase(const char* a, const AtomicString& b) { return equ alIgnoringCase(reinterpret_cast<const LChar*>(a), b.impl()); } 207 return a.impl() != b.impl();
209 inline bool equalIgnoringCase(const String& a, const AtomicString& b) { return e qualIgnoringCase(a.impl(), b.impl()); } 208 }
209 inline bool operator!=(const AtomicString& a, const LChar* b) {
210 return !(a == b);
211 }
212 inline bool operator!=(const AtomicString& a, const char* b) {
213 return !(a == b);
214 }
215 inline bool operator!=(const AtomicString& a, const String& b) {
216 return !equal(a.impl(), b.impl());
217 }
218 inline bool operator!=(const AtomicString& a, const Vector<UChar>& b) {
219 return !(a == b);
220 }
221 inline bool operator!=(const LChar* a, const AtomicString& b) {
222 return !(b == a);
223 }
224 inline bool operator!=(const char* a, const AtomicString& b) {
225 return !(b == a);
226 }
227 inline bool operator!=(const String& a, const AtomicString& b) {
228 return !equal(a.impl(), b.impl());
229 }
230 inline bool operator!=(const Vector<UChar>& a, const AtomicString& b) {
231 return !(a == b);
232 }
233
234 inline bool equalIgnoringCase(const AtomicString& a, const AtomicString& b) {
235 return equalIgnoringCase(a.impl(), b.impl());
236 }
237 inline bool equalIgnoringCase(const AtomicString& a, const LChar* b) {
238 return equalIgnoringCase(a.impl(), b);
239 }
240 inline bool equalIgnoringCase(const AtomicString& a, const char* b) {
241 return equalIgnoringCase(a.impl(), reinterpret_cast<const LChar*>(b));
242 }
243 inline bool equalIgnoringCase(const AtomicString& a, const String& b) {
244 return equalIgnoringCase(a.impl(), b.impl());
245 }
246 inline bool equalIgnoringCase(const LChar* a, const AtomicString& b) {
247 return equalIgnoringCase(a, b.impl());
248 }
249 inline bool equalIgnoringCase(const char* a, const AtomicString& b) {
250 return equalIgnoringCase(reinterpret_cast<const LChar*>(a), b.impl());
251 }
252 inline bool equalIgnoringCase(const String& a, const AtomicString& b) {
253 return equalIgnoringCase(a.impl(), b.impl());
254 }
210 255
211 // Define external global variables for the commonly used atomic strings. 256 // Define external global variables for the commonly used atomic strings.
212 // These are only usable from the main thread. 257 // These are only usable from the main thread.
213 WTF_EXPORT extern const AtomicString& nullAtom; 258 WTF_EXPORT extern const AtomicString& nullAtom;
214 WTF_EXPORT extern const AtomicString& emptyAtom; 259 WTF_EXPORT extern const AtomicString& emptyAtom;
215 WTF_EXPORT extern const AtomicString& starAtom; 260 WTF_EXPORT extern const AtomicString& starAtom;
216 WTF_EXPORT extern const AtomicString& xmlAtom; 261 WTF_EXPORT extern const AtomicString& xmlAtom;
217 WTF_EXPORT extern const AtomicString& xmlnsAtom; 262 WTF_EXPORT extern const AtomicString& xmlnsAtom;
218 WTF_EXPORT extern const AtomicString& xlinkAtom; 263 WTF_EXPORT extern const AtomicString& xlinkAtom;
219 264
220 inline AtomicString AtomicString::fromUTF8(const char* characters, size_t length ) 265 inline AtomicString AtomicString::fromUTF8(const char* characters, size_t length ) {
221 { 266 if (!characters)
222 if (!characters) 267 return nullAtom;
223 return nullAtom; 268 if (!length)
224 if (!length) 269 return emptyAtom;
225 return emptyAtom; 270 return fromUTF8Internal(characters, characters + length);
226 return fromUTF8Internal(characters, characters + length);
227 } 271 }
228 272
229 inline AtomicString AtomicString::fromUTF8(const char* characters) 273 inline AtomicString AtomicString::fromUTF8(const char* characters) {
230 { 274 if (!characters)
231 if (!characters) 275 return nullAtom;
232 return nullAtom; 276 if (!*characters)
233 if (!*characters) 277 return emptyAtom;
234 return emptyAtom; 278 return fromUTF8Internal(characters, 0);
235 return fromUTF8Internal(characters, 0);
236 } 279 }
237 280
238 // AtomicStringHash is the default hash for AtomicString 281 // AtomicStringHash is the default hash for AtomicString
239 template<typename T> struct DefaultHash; 282 template <typename T>
240 template<> struct DefaultHash<AtomicString> { 283 struct DefaultHash;
241 typedef AtomicStringHash Hash; 284 template <>
285 struct DefaultHash<AtomicString> {
286 typedef AtomicStringHash Hash;
242 }; 287 };
243 288
244 } // namespace WTF 289 } // namespace WTF
245 290
246 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(AtomicString); 291 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(AtomicString);
247 292
248 using WTF::AtomicString; 293 using WTF::AtomicString;
249 using WTF::nullAtom; 294 using WTF::nullAtom;
250 using WTF::emptyAtom; 295 using WTF::emptyAtom;
251 using WTF::starAtom; 296 using WTF::starAtom;
252 using WTF::xmlAtom; 297 using WTF::xmlAtom;
253 using WTF::xmlnsAtom; 298 using WTF::xmlnsAtom;
254 using WTF::xlinkAtom; 299 using WTF::xlinkAtom;
255 300
256 #include "wtf/text/StringConcatenate.h" 301 #include "wtf/text/StringConcatenate.h"
257 #endif // AtomicString_h 302 #endif // AtomicString_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/ASCIIFastPath.h ('k') | third_party/WebKit/Source/wtf/text/AtomicString.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698