OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "wtf/text/AtomicStringTable.h" | 5 #include "wtf/text/AtomicStringTable.h" |
6 | 6 |
7 #include "wtf/text/StringHash.h" | 7 #include "wtf/text/StringHash.h" |
8 #include "wtf/text/UTF8.h" | 8 #include "wtf/text/UTF8.h" |
9 | 9 |
10 namespace WTF { | 10 namespace WTF { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 struct HashAndUTF8CharactersTranslator { | 75 struct HashAndUTF8CharactersTranslator { |
76 static unsigned hash(const HashAndUTF8Characters& buffer) { | 76 static unsigned hash(const HashAndUTF8Characters& buffer) { |
77 return buffer.hash; | 77 return buffer.hash; |
78 } | 78 } |
79 | 79 |
80 static bool equal(StringImpl* const& string, | 80 static bool equal(StringImpl* const& string, |
81 const HashAndUTF8Characters& buffer) { | 81 const HashAndUTF8Characters& buffer) { |
82 if (buffer.utf16Length != string->length()) | 82 if (buffer.utf16Length != string->length()) |
83 return false; | 83 return false; |
84 | 84 |
85 // If buffer contains only ASCII characters UTF-8 and UTF16 length are the s
ame. | 85 // If buffer contains only ASCII characters UTF-8 and UTF16 length are the |
| 86 // same. |
86 if (buffer.utf16Length != buffer.length) { | 87 if (buffer.utf16Length != buffer.length) { |
87 if (string->is8Bit()) { | 88 if (string->is8Bit()) { |
88 const LChar* characters8 = string->characters8(); | 89 const LChar* characters8 = string->characters8(); |
89 return equalLatin1WithUTF8(characters8, characters8 + string->length(), | 90 return equalLatin1WithUTF8(characters8, characters8 + string->length(), |
90 buffer.characters, | 91 buffer.characters, |
91 buffer.characters + buffer.length); | 92 buffer.characters + buffer.length); |
92 } | 93 } |
93 const UChar* characters16 = string->characters16(); | 94 const UChar* characters16 = string->characters16(); |
94 return equalUTF16WithUTF8(characters16, characters16 + string->length(), | 95 return equalUTF16WithUTF8(characters16, characters16 + string->length(), |
95 buffer.characters, | 96 buffer.characters, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 212 } |
212 | 213 |
213 void AtomicStringTable::remove(StringImpl* string) { | 214 void AtomicStringTable::remove(StringImpl* string) { |
214 DCHECK(string->isAtomic()); | 215 DCHECK(string->isAtomic()); |
215 auto iterator = m_table.find(string); | 216 auto iterator = m_table.find(string); |
216 RELEASE_ASSERT(iterator != m_table.end()); | 217 RELEASE_ASSERT(iterator != m_table.end()); |
217 m_table.remove(iterator); | 218 m_table.remove(iterator); |
218 } | 219 } |
219 | 220 |
220 } // namespace WTF | 221 } // namespace WTF |
OLD | NEW |