Changeset 65104 in webkit for trunk/JavaScriptCore/runtime/Identifier.cpp
- Timestamp:
- Aug 10, 2010, 5:16:38 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/Identifier.cpp
r60762 r65104 66 66 } 67 67 68 bool Identifier::equal(const UString::Rep* r, const char* s)68 bool Identifier::equal(const StringImpl* r, const char* s) 69 69 { 70 70 int length = r->length(); … … 76 76 } 77 77 78 bool Identifier::equal(const UString::Rep* r, const UChar* s, unsigned length)78 bool Identifier::equal(const StringImpl* r, const UChar* s, unsigned length) 79 79 { 80 80 if (r->length() != length) … … 90 90 static unsigned hash(const char* c) 91 91 { 92 return UString::Rep::computeHash(c);93 } 94 95 static bool equal( UString::Rep* r, const char* s)92 return StringImpl::computeHash(c); 93 } 94 95 static bool equal(StringImpl* r, const char* s) 96 96 { 97 97 return Identifier::equal(r, s); 98 98 } 99 99 100 static void translate( UString::Rep*& location, const char* c, unsigned hash)100 static void translate(StringImpl*& location, const char* c, unsigned hash) 101 101 { 102 102 size_t length = strlen(c); 103 103 UChar* d; 104 UString::Rep* r = UString::Rep::createUninitialized(length, d).releaseRef();104 StringImpl* r = StringImpl::createUninitialized(length, d).releaseRef(); 105 105 for (size_t i = 0; i != length; i++) 106 106 d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend … … 110 110 }; 111 111 112 PassRefPtr< UString::Rep> Identifier::add(JSGlobalData* globalData, const char* c)112 PassRefPtr<StringImpl> Identifier::add(JSGlobalData* globalData, const char* c) 113 113 { 114 114 if (!c) 115 return UString::null().rep();115 return 0; 116 116 if (!c[0]) 117 return UString::Rep::empty();117 return StringImpl::empty(); 118 118 if (!c[1]) 119 119 return add(globalData, globalData->smallStrings.singleCharacterStringRep(static_cast<unsigned char>(c[0]))); … … 126 126 return iter->second; 127 127 128 pair<HashSet< UString::Rep*>::iterator, bool> addResult = identifierTable.add<const char*, IdentifierCStringTranslator>(c);128 pair<HashSet<StringImpl*>::iterator, bool> addResult = identifierTable.add<const char*, IdentifierCStringTranslator>(c); 129 129 130 130 // If the string is newly-translated, then we need to adopt it. 131 131 // The boolean in the pair tells us if that is so. 132 RefPtr< UString::Rep> addedString = addResult.second ? adoptRef(*addResult.first) : *addResult.first;132 RefPtr<StringImpl> addedString = addResult.second ? adoptRef(*addResult.first) : *addResult.first; 133 133 134 134 literalIdentifierTable.add(c, addedString.get()); … … 137 137 } 138 138 139 PassRefPtr< UString::Rep> Identifier::add(ExecState* exec, const char* c)139 PassRefPtr<StringImpl> Identifier::add(ExecState* exec, const char* c) 140 140 { 141 141 return add(&exec->globalData(), c); … … 150 150 static unsigned hash(const UCharBuffer& buf) 151 151 { 152 return UString::Rep::computeHash(buf.s, buf.length);153 } 154 155 static bool equal( UString::Rep* str, const UCharBuffer& buf)152 return StringImpl::computeHash(buf.s, buf.length); 153 } 154 155 static bool equal(StringImpl* str, const UCharBuffer& buf) 156 156 { 157 157 return Identifier::equal(str, buf.s, buf.length); 158 158 } 159 159 160 static void translate( UString::Rep*& location, const UCharBuffer& buf, unsigned hash)160 static void translate(StringImpl*& location, const UCharBuffer& buf, unsigned hash) 161 161 { 162 162 UChar* d; 163 UString::Rep* r = UString::Rep::createUninitialized(buf.length, d).releaseRef();163 StringImpl* r = StringImpl::createUninitialized(buf.length, d).releaseRef(); 164 164 for (unsigned i = 0; i != buf.length; i++) 165 165 d[i] = buf.s[i]; … … 169 169 }; 170 170 171 PassRefPtr< UString::Rep> Identifier::add(JSGlobalData* globalData, const UChar* s, int length)171 PassRefPtr<StringImpl> Identifier::add(JSGlobalData* globalData, const UChar* s, int length) 172 172 { 173 173 if (length == 1) { … … 177 177 } 178 178 if (!length) 179 return UString::Rep::empty();179 return StringImpl::empty(); 180 180 UCharBuffer buf = {s, length}; 181 pair<HashSet< UString::Rep*>::iterator, bool> addResult = globalData->identifierTable->add<UCharBuffer, IdentifierUCharBufferTranslator>(buf);181 pair<HashSet<StringImpl*>::iterator, bool> addResult = globalData->identifierTable->add<UCharBuffer, IdentifierUCharBufferTranslator>(buf); 182 182 183 183 // If the string is newly-translated, then we need to adopt it. … … 186 186 } 187 187 188 PassRefPtr< UString::Rep> Identifier::add(ExecState* exec, const UChar* s, int length)188 PassRefPtr<StringImpl> Identifier::add(ExecState* exec, const UChar* s, int length) 189 189 { 190 190 return add(&exec->globalData(), s, length); 191 191 } 192 192 193 PassRefPtr< UString::Rep> Identifier::addSlowCase(JSGlobalData* globalData, UString::Rep* r)193 PassRefPtr<StringImpl> Identifier::addSlowCase(JSGlobalData* globalData, StringImpl* r) 194 194 { 195 195 ASSERT(!r->isIdentifier()); … … 209 209 } 210 210 211 PassRefPtr< UString::Rep> Identifier::addSlowCase(ExecState* exec, UString::Rep* r)211 PassRefPtr<StringImpl> Identifier::addSlowCase(ExecState* exec, StringImpl* r) 212 212 { 213 213 return addSlowCase(&exec->globalData(), r);
Note:
See TracChangeset
for help on using the changeset viewer.