OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> | 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> |
4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 * | 20 * |
21 */ | 21 */ |
22 | 22 |
23 #include "wtf/text/AtomicString.h" | 23 #include "wtf/text/AtomicString.h" |
24 | 24 |
25 #include "wtf/dtoa.h" | 25 #include "wtf/dtoa.h" |
26 #include "wtf/text/AtomicStringTable.h" | 26 #include "wtf/text/AtomicStringTable.h" |
27 #include "wtf/text/IntegerToStringConversion.h" | 27 #include "wtf/text/IntegerToStringConversion.h" |
| 28 #include "wtf/text/StringImpl.h" |
28 | 29 |
29 namespace WTF { | 30 namespace WTF { |
30 | 31 |
31 static_assert(sizeof(AtomicString) == sizeof(String), "AtomicString and String m
ust be same size"); | 32 static_assert(sizeof(AtomicString) == sizeof(String), "AtomicString and String m
ust be same size"); |
32 | 33 |
33 AtomicString::AtomicString(const LChar* chars, unsigned length) | 34 AtomicString::AtomicString(const LChar* chars, unsigned length) |
34 : m_string(AtomicStringTable::instance().add(chars, length)) {} | 35 : m_string(AtomicStringTable::instance().add(chars, length)) {} |
35 | 36 |
36 AtomicString::AtomicString(const UChar* chars, unsigned length) | 37 AtomicString::AtomicString(const UChar* chars, unsigned length) |
37 : m_string(AtomicStringTable::instance().add(chars, length)) {} | 38 : m_string(AtomicStringTable::instance().add(chars, length)) {} |
38 | 39 |
39 AtomicString::AtomicString(const UChar* chars, unsigned length, unsigned existin
gHash) | 40 AtomicString::AtomicString(const UChar* chars) |
40 : m_string(AtomicStringTable::instance().add(chars, length, existingHash)) {
} | 41 : m_string(AtomicStringTable::instance().add(chars, chars ? lengthOfNullTerm
inatedString(chars) : 0)) {} |
41 | 42 |
42 AtomicString::AtomicString(const UChar* chars) | 43 PassRefPtr<StringImpl> AtomicString::addSlowCase(StringImpl* string) |
43 : m_string(AtomicStringTable::instance().add(chars)) {} | |
44 | |
45 AtomicString::AtomicString(StringImpl* string, unsigned offset, unsigned length) | |
46 : m_string(AtomicStringTable::instance().add(string, offset, length)) {} | |
47 | |
48 PassRefPtr<StringImpl> AtomicString::addSlowCase(StringImpl* chars) | |
49 { | 44 { |
50 DCHECK(!chars->isAtomic()); | 45 DCHECK(!string->isAtomic()); |
51 return AtomicStringTable::instance().add(chars); | 46 return AtomicStringTable::instance().add(string); |
52 } | 47 } |
53 | 48 |
54 AtomicString AtomicString::fromUTF8(const char* chars, size_t length) | 49 AtomicString AtomicString::fromUTF8(const char* chars, size_t length) |
55 { | 50 { |
56 if (!chars) | 51 if (!chars) |
57 return nullAtom; | 52 return nullAtom; |
58 if (!length) | 53 if (!length) |
59 return emptyAtom; | 54 return emptyAtom; |
60 return AtomicString(AtomicStringTable::instance().addUTF8(chars, chars + len
gth)); | 55 return AtomicString(AtomicStringTable::instance().addUTF8(chars, chars + len
gth)); |
61 } | 56 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 136 } |
142 | 137 |
143 #ifndef NDEBUG | 138 #ifndef NDEBUG |
144 void AtomicString::show() const | 139 void AtomicString::show() const |
145 { | 140 { |
146 m_string.show(); | 141 m_string.show(); |
147 } | 142 } |
148 #endif | 143 #endif |
149 | 144 |
150 } // namespace WTF | 145 } // namespace WTF |
OLD | NEW |