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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 | 73 |
74 void AtomicString::init() | 74 void AtomicString::init() |
75 { | 75 { |
76 ASSERT(isMainThread()); | 76 ASSERT(isMainThread()); |
77 | 77 |
78 new (NotNull, (void*)&nullAtom) AtomicString; | 78 new (NotNull, (void*)&nullAtom) AtomicString; |
79 new (NotNull, (void*)&emptyAtom) AtomicString(""); | 79 new (NotNull, (void*)&emptyAtom) AtomicString(""); |
80 } | 80 } |
81 | 81 |
| 82 template<unsigned charactersCount> |
| 83 PassRefPtr<StringImpl> addStaticASCIILiteral(const char (&characters)[characters
Count]) |
| 84 { |
| 85 unsigned length = charactersCount - 1; |
| 86 unsigned hash = StringHasher::computeHashAndMaskTop8Bits(reinterpret_cast<co
nst LChar*>(characters), length); |
| 87 return adoptRef(StringImpl::createStatic(characters, length, hash)); |
| 88 } |
| 89 |
82 void StringStatics::init() | 90 void StringStatics::init() |
83 { | 91 { |
84 ASSERT(isMainThread()); | 92 ASSERT(isMainThread()); |
85 | 93 |
86 // FIXME: These should be allocated at compile time. | 94 // FIXME: These should be allocated at compile time. |
87 new (NotNull, (void*)&starAtom) AtomicString("*", AtomicString::ConstructFro
mLiteral); | 95 new (NotNull, (void*)&starAtom) AtomicString("*", AtomicString::ConstructFro
mLiteral); |
88 new (NotNull, (void*)&xmlAtom) AtomicString("xml", AtomicString::ConstructFr
omLiteral); | 96 new (NotNull, (void*)&xmlAtom) AtomicString(addStaticASCIILiteral("xml")); |
89 new (NotNull, (void*)&xmlnsAtom) AtomicString("xmlns", AtomicString::Constru
ctFromLiteral); | 97 new (NotNull, (void*)&xmlnsAtom) AtomicString(addStaticASCIILiteral("xmlns")
); |
90 new (NotNull, (void*)&xlinkAtom) AtomicString("xlink", AtomicString::Constru
ctFromLiteral); | 98 new (NotNull, (void*)&xlinkAtom) AtomicString(addStaticASCIILiteral("xlink")
); |
91 new (NotNull, (void*)&xmlnsWithColon) String("xmlns:"); | 99 new (NotNull, (void*)&xmlnsWithColon) String("xmlns:"); |
92 } | 100 } |
93 | 101 |
94 } | 102 } |
OLD | NEW |