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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 template<typename CharType> | 101 template<typename CharType> |
102 inline bool isNotHTMLSpace(CharType character) | 102 inline bool isNotHTMLSpace(CharType character) |
103 { | 103 { |
104 return !isHTMLSpace<CharType>(character); | 104 return !isHTMLSpace<CharType>(character); |
105 } | 105 } |
106 | 106 |
107 bool threadSafeMatch(const QualifiedName&, const QualifiedName&); | 107 bool threadSafeMatch(const QualifiedName&, const QualifiedName&); |
108 bool threadSafeMatch(const String&, const QualifiedName&); | 108 bool threadSafeMatch(const String&, const QualifiedName&); |
109 | 109 |
110 StringImpl* findStringIfStatic(const UChar* characters, unsigned length); | |
111 | |
112 enum CharacterWidth { | 110 enum CharacterWidth { |
113 Likely8Bit, | 111 Likely8Bit, |
114 Force8Bit, | 112 Force8Bit, |
115 Force16Bit | 113 Force16Bit |
116 }; | 114 }; |
117 | 115 |
| 116 String attemptStaticStringCreation(const LChar*, size_t); |
| 117 |
| 118 String attemptStaticStringCreation(const UChar*, size_t, CharacterWidth); |
| 119 |
118 template<size_t inlineCapacity> | 120 template<size_t inlineCapacity> |
119 static String attemptStaticStringCreation(const Vector<UChar, inlineCapacity>& v
ector, CharacterWidth width) | 121 inline static String attemptStaticStringCreation(const Vector<UChar, inlineCapac
ity>& vector, CharacterWidth width) |
120 { | 122 { |
121 String string(findStringIfStatic(vector.data(), vector.size())); | 123 return attemptStaticStringCreation(vector.data(), vector.size(), width); |
122 if (string.impl()) | 124 } |
123 return string; | |
124 if (width == Likely8Bit) | |
125 string = StringImpl::create8BitIfPossible(vector); | |
126 else if (width == Force8Bit) | |
127 string = String::make8BitFrom16BitSource(vector); | |
128 else | |
129 string = String(vector); | |
130 | 125 |
131 return string; | 126 inline static String attemptStaticStringCreation(const String str) |
| 127 { |
| 128 if (!str.is8Bit()) |
| 129 return attemptStaticStringCreation(str.characters16(), str.length(), For
ce16Bit); |
| 130 return attemptStaticStringCreation(str.characters8(), str.length()); |
132 } | 131 } |
133 | 132 |
| 133 |
134 } | 134 } |
135 #endif | 135 #endif |
OLD | NEW |