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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 bool isAllASCII; | 130 bool isAllASCII; |
131 const char* source = buffer.characters; | 131 const char* source = buffer.characters; |
132 if (convertUTF8ToUTF16(&source, source + buffer.length, &target, | 132 if (convertUTF8ToUTF16(&source, source + buffer.length, &target, |
133 target + buffer.utf16Length, | 133 target + buffer.utf16Length, |
134 &isAllASCII) != conversionOK) | 134 &isAllASCII) != conversionOK) |
135 NOTREACHED(); | 135 NOTREACHED(); |
136 | 136 |
137 if (isAllASCII) | 137 if (isAllASCII) |
138 newString = StringImpl::create(buffer.characters, buffer.length); | 138 newString = StringImpl::create(buffer.characters, buffer.length); |
139 | 139 |
140 location = newString.release().leakRef(); | 140 location = newString.leakRef(); |
141 location->setHash(hash); | 141 location->setHash(hash); |
142 location->setIsAtomic(true); | 142 location->setIsAtomic(true); |
143 } | 143 } |
144 }; | 144 }; |
145 | 145 |
146 PassRefPtr<StringImpl> AtomicStringTable::add(const UChar* s, unsigned length) { | 146 PassRefPtr<StringImpl> AtomicStringTable::add(const UChar* s, unsigned length) { |
147 if (!s) | 147 if (!s) |
148 return nullptr; | 148 return nullptr; |
149 | 149 |
150 if (!length) | 150 if (!length) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 212 } |
213 | 213 |
214 void AtomicStringTable::remove(StringImpl* string) { | 214 void AtomicStringTable::remove(StringImpl* string) { |
215 DCHECK(string->isAtomic()); | 215 DCHECK(string->isAtomic()); |
216 auto iterator = m_table.find(string); | 216 auto iterator = m_table.find(string); |
217 RELEASE_ASSERT(iterator != m_table.end()); | 217 RELEASE_ASSERT(iterator != m_table.end()); |
218 m_table.remove(iterator); | 218 m_table.remove(iterator); |
219 } | 219 } |
220 | 220 |
221 } // namespace WTF | 221 } // namespace WTF |
OLD | NEW |