| 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 28 matching lines...) Expand all Loading... |
| 39 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xmlnsAtom); | 39 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xmlnsAtom); |
| 40 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xlinkAtom); | 40 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xlinkAtom); |
| 41 WTF_EXPORT DEFINE_GLOBAL(AtomicString, httpAtom); | 41 WTF_EXPORT DEFINE_GLOBAL(AtomicString, httpAtom); |
| 42 WTF_EXPORT DEFINE_GLOBAL(AtomicString, httpsAtom); | 42 WTF_EXPORT DEFINE_GLOBAL(AtomicString, httpsAtom); |
| 43 | 43 |
| 44 // 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 |
| 45 // event/element/attribute name, so it shouldn't pollute the AtomicString hash | 45 // event/element/attribute name, so it shouldn't pollute the AtomicString hash |
| 46 // table. | 46 // table. |
| 47 WTF_EXPORT DEFINE_GLOBAL(String, xmlnsWithColon); | 47 WTF_EXPORT DEFINE_GLOBAL(String, xmlnsWithColon); |
| 48 | 48 |
| 49 WTF_EXPORT DEFINE_GLOBAL(String, emptyString); |
| 50 WTF_EXPORT DEFINE_GLOBAL(String, emptyString16Bit); |
| 51 |
| 49 NEVER_INLINE unsigned StringImpl::hashSlowCase() const { | 52 NEVER_INLINE unsigned StringImpl::hashSlowCase() const { |
| 50 if (is8Bit()) | 53 if (is8Bit()) |
| 51 setHash(StringHasher::computeHashAndMaskTop8Bits(characters8(), m_length)); | 54 setHash(StringHasher::computeHashAndMaskTop8Bits(characters8(), m_length)); |
| 52 else | 55 else |
| 53 setHash(StringHasher::computeHashAndMaskTop8Bits(characters16(), m_length)); | 56 setHash(StringHasher::computeHashAndMaskTop8Bits(characters16(), m_length)); |
| 54 return existingHash(); | 57 return existingHash(); |
| 55 } | 58 } |
| 56 | 59 |
| 57 void AtomicString::init() { | 60 void AtomicString::init() { |
| 58 DCHECK(isMainThread()); | 61 DCHECK(isMainThread()); |
| 59 | 62 |
| 60 new (NotNull, (void*)&nullAtom) AtomicString; | 63 new (NotNull, (void*)&nullAtom) AtomicString; |
| 61 new (NotNull, (void*)&emptyAtom) AtomicString(""); | 64 new (NotNull, (void*)&emptyAtom) AtomicString(""); |
| 62 } | 65 } |
| 63 | 66 |
| 64 template <unsigned charactersCount> | 67 template <unsigned charactersCount> |
| 65 PassRefPtr<StringImpl> addStaticASCIILiteral( | 68 PassRefPtr<StringImpl> addStaticASCIILiteral( |
| 66 const char (&characters)[charactersCount]) { | 69 const char (&characters)[charactersCount]) { |
| 67 unsigned length = charactersCount - 1; | 70 unsigned length = charactersCount - 1; |
| 68 unsigned hash = StringHasher::computeHashAndMaskTop8Bits( | 71 unsigned hash = StringHasher::computeHashAndMaskTop8Bits( |
| 69 reinterpret_cast<const LChar*>(characters), length); | 72 reinterpret_cast<const LChar*>(characters), length); |
| 70 return adoptRef(StringImpl::createStatic(characters, length, hash)); | 73 return adoptRef(StringImpl::createStatic(characters, length, hash)); |
| 71 } | 74 } |
| 72 | 75 |
| 73 void StringStatics::init() { | 76 void StringStatics::init() { |
| 74 DCHECK(isMainThread()); | 77 DCHECK(isMainThread()); |
| 75 | 78 |
| 76 StringImpl::initStatics(); | 79 StringImpl::initStatics(); |
| 80 new (NotNull, (void*)&emptyString) String(StringImpl::empty); |
| 81 new (NotNull, (void*)&emptyString16Bit) String(StringImpl::empty16Bit); |
| 77 | 82 |
| 78 // FIXME: These should be allocated at compile time. | 83 // FIXME: These should be allocated at compile time. |
| 79 new (NotNull, (void*)&starAtom) AtomicString("*"); | 84 new (NotNull, (void*)&starAtom) AtomicString("*"); |
| 80 new (NotNull, (void*)&xmlAtom) AtomicString(addStaticASCIILiteral("xml")); | 85 new (NotNull, (void*)&xmlAtom) AtomicString(addStaticASCIILiteral("xml")); |
| 81 new (NotNull, (void*)&xmlnsAtom) AtomicString(addStaticASCIILiteral("xmlns")); | 86 new (NotNull, (void*)&xmlnsAtom) AtomicString(addStaticASCIILiteral("xmlns")); |
| 82 new (NotNull, (void*)&xlinkAtom) AtomicString(addStaticASCIILiteral("xlink")); | 87 new (NotNull, (void*)&xlinkAtom) AtomicString(addStaticASCIILiteral("xlink")); |
| 83 new (NotNull, (void*)&xmlnsWithColon) String("xmlns:"); | 88 new (NotNull, (void*)&xmlnsWithColon) String("xmlns:"); |
| 84 new (NotNull, (void*)&httpAtom) AtomicString(addStaticASCIILiteral("http")); | 89 new (NotNull, (void*)&httpAtom) AtomicString(addStaticASCIILiteral("http")); |
| 85 new (NotNull, (void*)&httpsAtom) AtomicString(addStaticASCIILiteral("https")); | 90 new (NotNull, (void*)&httpsAtom) AtomicString(addStaticASCIILiteral("https")); |
| 86 } | 91 } |
| 87 | 92 |
| 88 } // namespace WTF | 93 } // namespace WTF |
| OLD | NEW |