Changeset 36124 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Sep 5, 2008, 9:58:40 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/SmallStrings.cpp
r36006 r36124 102 102 } 103 103 104 UString::Rep* SmallStrings::singleCharacterStringRep(unsigned char character) 105 { 106 if (!m_storage) 107 m_storage.set(new SmallStringsStorage); 108 return m_storage->rep(character); 104 109 } 110 111 } -
trunk/JavaScriptCore/kjs/SmallStrings.h
r36006 r36124 27 27 #define SmallStrings_h 28 28 29 #include "ustring.h" 29 30 #include <wtf/OwnPtr.h> 30 31 … … 53 54 return m_singleCharacterStrings[character]; 54 55 } 56 57 UString::Rep* singleCharacterStringRep(unsigned char character); 55 58 56 59 void mark(); -
trunk/JavaScriptCore/kjs/identifier.cpp
r35898 r36124 130 130 return &UString::Rep::null; 131 131 } 132 133 132 if (!c[0]) { 134 133 UString::Rep::empty.hash(); 135 134 return &UString::Rep::empty; 136 135 } 136 if (!c[1]) 137 return add(globalData, globalData->smallStrings.singleCharacterStringRep(static_cast<unsigned char>(c[0]))); 137 138 138 139 IdentifierTable& identifierTable = *globalData->identifierTable; … … 187 188 PassRefPtr<UString::Rep> Identifier::add(JSGlobalData* globalData, const UChar* s, int length) 188 189 { 190 if (length == 1) { 191 UChar c = s[0]; 192 if (c <= 0xFF) 193 return add(globalData, globalData->smallStrings.singleCharacterStringRep(c)); 194 } 189 195 if (!length) { 190 196 UString::Rep::empty.hash(); 191 197 return &UString::Rep::empty; 192 198 } 193 194 199 UCharBuffer buf = {s, length}; 195 200 return *globalData->identifierTable->add<UCharBuffer, UCharBufferTranslator>(buf).first; … … 204 209 { 205 210 ASSERT(!r->identifierTable()); 206 207 if (r->len == 0) { 211 if (r->len == 1) { 212 UChar c = r->data()[0]; 213 if (c <= 0xFF) 214 r = globalData->smallStrings.singleCharacterStringRep(c); 215 if (r->identifierTable()) { 216 checkSameIdentifierTable(globalData, r); 217 return r; 218 } 219 } 220 if (!r->len) { 208 221 UString::Rep::empty.hash(); 209 222 return &UString::Rep::empty; 210 223 } 211 212 224 return *globalData->identifierTable->add(r).first; 213 225 } … … 224 236 225 237 #ifndef NDEBUG 238 226 239 void Identifier::checkSameIdentifierTable(ExecState* exec, UString::Rep* rep) 227 240 { … … 233 246 ASSERT(rep->identifierTable() == globalData->identifierTable); 234 247 } 235 #else 236 void Identifier::checkSameIdentifierTable(ExecState*, UString::Rep*) 237 { 238 } 239 240 void Identifier::checkSameIdentifierTable(JSGlobalData*, UString::Rep*) 241 { 242 } 248 243 249 #endif 244 250 -
trunk/JavaScriptCore/kjs/identifier.h
r35776 r36124 93 93 { 94 94 if (r->identifierTable()) { 95 #ifndef NDEBUG96 95 checkSameIdentifierTable(exec, r); 97 #endif98 96 return r; 99 97 } … … 103 101 { 104 102 if (r->identifierTable()) { 105 #ifndef NDEBUG106 103 checkSameIdentifierTable(globalData, r); 107 #endif108 104 return r; 109 105 } … … 136 132 void deleteIdentifierTable(IdentifierTable*); 137 133 134 #ifdef NDEBUG 135 inline void Identifier::checkSameIdentifierTable(ExecState*, UString::Rep*) { } 136 inline void Identifier::checkSameIdentifierTable(JSGlobalData*, UString::Rep*) { } 137 #endif 138 138 139 } // namespace KJS 139 140
Note:
See TracChangeset
for help on using the changeset viewer.