OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "wtf/text/AtomicStringTable.h" |
| 6 |
| 7 namespace WTF { |
| 8 |
| 9 AtomicStringTable::AtomicStringTable() |
| 10 { |
| 11 for (StringImpl* string : StringImpl::allStaticStrings().values()) |
| 12 addStringImpl(string); |
| 13 } |
| 14 |
| 15 AtomicStringTable::~AtomicStringTable() |
| 16 { |
| 17 for (StringImpl* string : m_table) { |
| 18 if (!string->isStatic()) { |
| 19 DCHECK(string->isAtomic()); |
| 20 string->setIsAtomic(false); |
| 21 } |
| 22 } |
| 23 } |
| 24 |
| 25 StringImpl* AtomicStringTable::addStringImpl(StringImpl* string) |
| 26 { |
| 27 if (!string->length()) |
| 28 return StringImpl::empty(); |
| 29 |
| 30 StringImpl* result = *m_table.add(string).storedValue; |
| 31 |
| 32 if (!result->isAtomic()) |
| 33 result->setIsAtomic(true); |
| 34 |
| 35 DCHECK(!string->isStatic() || result->isStatic()); |
| 36 return result; |
| 37 } |
| 38 |
| 39 } // namespace WTF |
OLD | NEW |