| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "wtf/text/StringStatics.h" | 26 #include "wtf/text/StringStatics.h" |
| 27 | 27 |
| 28 #include "wtf/DynamicAnnotations.h" | 28 #include "wtf/DynamicAnnotations.h" |
| 29 #include "wtf/StaticConstructors.h" | 29 #include "wtf/StaticConstructors.h" |
| 30 #include "wtf/text/AtomicString.h" | 30 #include "wtf/text/AtomicString.h" |
| 31 #include "wtf/text/StringImpl.h" | 31 #include "wtf/text/StringImpl.h" |
| 32 | 32 |
| 33 namespace WTF { | 33 namespace WTF { |
| 34 | 34 |
| 35 StringImpl* StringImpl::empty() { | |
| 36 DEFINE_STATIC_LOCAL(StringImpl, emptyString, (ConstructEmptyString)); | |
| 37 WTF_ANNOTATE_BENIGN_RACE(&emptyString, | |
| 38 "Benign race on the reference counter of a static " | |
| 39 "string created by StringImpl::empty"); | |
| 40 return &emptyString; | |
| 41 } | |
| 42 | |
| 43 StringImpl* StringImpl::empty16Bit() { | |
| 44 DEFINE_STATIC_LOCAL(StringImpl, emptyString, (ConstructEmptyString16Bit)); | |
| 45 WTF_ANNOTATE_BENIGN_RACE(&emptyString, | |
| 46 "Benign race on the reference counter of a static " | |
| 47 "string created by StringImpl::empty16Bit"); | |
| 48 return &emptyString; | |
| 49 } | |
| 50 | |
| 51 WTF_EXPORT DEFINE_GLOBAL(AtomicString, nullAtom); | 35 WTF_EXPORT DEFINE_GLOBAL(AtomicString, nullAtom); |
| 52 WTF_EXPORT DEFINE_GLOBAL(AtomicString, emptyAtom); | 36 WTF_EXPORT DEFINE_GLOBAL(AtomicString, emptyAtom); |
| 53 WTF_EXPORT DEFINE_GLOBAL(AtomicString, starAtom); | 37 WTF_EXPORT DEFINE_GLOBAL(AtomicString, starAtom); |
| 54 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xmlAtom); | 38 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xmlAtom); |
| 55 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xmlnsAtom); | 39 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xmlnsAtom); |
| 56 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xlinkAtom); | 40 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xlinkAtom); |
| 57 WTF_EXPORT DEFINE_GLOBAL(AtomicString, httpAtom); | 41 WTF_EXPORT DEFINE_GLOBAL(AtomicString, httpAtom); |
| 58 WTF_EXPORT DEFINE_GLOBAL(AtomicString, httpsAtom); | 42 WTF_EXPORT DEFINE_GLOBAL(AtomicString, httpsAtom); |
| 59 | 43 |
| 60 // This is not an AtomicString because it is unlikely to be used as an | 44 // This is not an AtomicString because it is unlikely to be used as an |
| (...skipping 21 matching lines...) Expand all Loading... |
| 82 const char (&characters)[charactersCount]) { | 66 const char (&characters)[charactersCount]) { |
| 83 unsigned length = charactersCount - 1; | 67 unsigned length = charactersCount - 1; |
| 84 unsigned hash = StringHasher::computeHashAndMaskTop8Bits( | 68 unsigned hash = StringHasher::computeHashAndMaskTop8Bits( |
| 85 reinterpret_cast<const LChar*>(characters), length); | 69 reinterpret_cast<const LChar*>(characters), length); |
| 86 return adoptRef(StringImpl::createStatic(characters, length, hash)); | 70 return adoptRef(StringImpl::createStatic(characters, length, hash)); |
| 87 } | 71 } |
| 88 | 72 |
| 89 void StringStatics::init() { | 73 void StringStatics::init() { |
| 90 DCHECK(isMainThread()); | 74 DCHECK(isMainThread()); |
| 91 | 75 |
| 76 StringImpl::initStatics(); |
| 77 |
| 92 // FIXME: These should be allocated at compile time. | 78 // FIXME: These should be allocated at compile time. |
| 93 new (NotNull, (void*)&starAtom) AtomicString("*"); | 79 new (NotNull, (void*)&starAtom) AtomicString("*"); |
| 94 new (NotNull, (void*)&xmlAtom) AtomicString(addStaticASCIILiteral("xml")); | 80 new (NotNull, (void*)&xmlAtom) AtomicString(addStaticASCIILiteral("xml")); |
| 95 new (NotNull, (void*)&xmlnsAtom) AtomicString(addStaticASCIILiteral("xmlns")); | 81 new (NotNull, (void*)&xmlnsAtom) AtomicString(addStaticASCIILiteral("xmlns")); |
| 96 new (NotNull, (void*)&xlinkAtom) AtomicString(addStaticASCIILiteral("xlink")); | 82 new (NotNull, (void*)&xlinkAtom) AtomicString(addStaticASCIILiteral("xlink")); |
| 97 new (NotNull, (void*)&xmlnsWithColon) String("xmlns:"); | 83 new (NotNull, (void*)&xmlnsWithColon) String("xmlns:"); |
| 98 new (NotNull, (void*)&httpAtom) AtomicString(addStaticASCIILiteral("http")); | 84 new (NotNull, (void*)&httpAtom) AtomicString(addStaticASCIILiteral("http")); |
| 99 new (NotNull, (void*)&httpsAtom) AtomicString(addStaticASCIILiteral("https")); | 85 new (NotNull, (void*)&httpsAtom) AtomicString(addStaticASCIILiteral("https")); |
| 100 } | 86 } |
| 101 | 87 |
| 102 } // namespace WTF | 88 } // namespace WTF |
| OLD | NEW |