Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 16 matching lines...) Expand all Loading... | |
| 27 #include "wtf/text/CString.h" | 27 #include "wtf/text/CString.h" |
| 28 #include "wtf/text/StringView.h" | 28 #include "wtf/text/StringView.h" |
| 29 #include "wtf/text/WTFString.h" | 29 #include "wtf/text/WTFString.h" |
| 30 #include <cstring> | 30 #include <cstring> |
| 31 #include <iosfwd> | 31 #include <iosfwd> |
| 32 | 32 |
| 33 namespace WTF { | 33 namespace WTF { |
| 34 | 34 |
| 35 struct AtomicStringHash; | 35 struct AtomicStringHash; |
| 36 | 36 |
| 37 // An AtomicString instance represents a string, and multiple AtomicString | |
| 38 // instances can shares their string storage if the strings are | |
|
kochi
2016/12/01 07:16:56
nit: can share (without s)
tkent
2016/12/01 08:24:30
oops. Done.
| |
| 39 // identical. Comparing two AtomicString instances is much faster than comparing | |
| 40 // two String instances because we just check string storage identity. | |
| 41 // | |
| 42 // AtomicString instances are not thread-safe. An AtomicString instance created | |
| 43 // in a thread must be used only in the creator thread. If multiple threads | |
| 44 // access a single AtomicString instance, we have race condition of a reference | |
| 45 // count in StringImpl, and would hit a runtime CHECK in | |
| 46 // AtomicStringTable::remove(). | |
| 47 // | |
| 48 // Exception: nullAtom and emptyAtom, are shared in multiple threads, and are | |
| 49 // never stored in AtomicStringTable. | |
| 37 class WTF_EXPORT AtomicString { | 50 class WTF_EXPORT AtomicString { |
| 38 USING_FAST_MALLOC(AtomicString); | 51 USING_FAST_MALLOC(AtomicString); |
| 39 | 52 |
| 40 public: | 53 public: |
| 54 // The function is defined in StringStatics.cpp. | |
| 41 static void init(); | 55 static void init(); |
| 42 | 56 |
| 43 AtomicString() {} | 57 AtomicString() {} |
| 44 AtomicString(const LChar* chars) | 58 AtomicString(const LChar* chars) |
| 45 : AtomicString(chars, | 59 : AtomicString(chars, |
| 46 chars ? strlen(reinterpret_cast<const char*>(chars)) : 0) { | 60 chars ? strlen(reinterpret_cast<const char*>(chars)) : 0) { |
| 47 } | 61 } |
| 48 AtomicString(const char* chars) | 62 AtomicString(const char* chars) |
| 49 : AtomicString(reinterpret_cast<const LChar*>(chars)) {} | 63 : AtomicString(reinterpret_cast<const LChar*>(chars)) {} |
| 50 AtomicString(const LChar* chars, unsigned length); | 64 AtomicString(const LChar* chars, unsigned length); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 using WTF::AtomicString; | 320 using WTF::AtomicString; |
| 307 using WTF::nullAtom; | 321 using WTF::nullAtom; |
| 308 using WTF::emptyAtom; | 322 using WTF::emptyAtom; |
| 309 using WTF::starAtom; | 323 using WTF::starAtom; |
| 310 using WTF::xmlAtom; | 324 using WTF::xmlAtom; |
| 311 using WTF::xmlnsAtom; | 325 using WTF::xmlnsAtom; |
| 312 using WTF::xlinkAtom; | 326 using WTF::xlinkAtom; |
| 313 | 327 |
| 314 #include "wtf/text/StringConcatenate.h" | 328 #include "wtf/text/StringConcatenate.h" |
| 315 #endif // AtomicString_h | 329 #endif // AtomicString_h |
| OLD | NEW |