Changeset 106167 in webkit
- Timestamp:
- Jan 27, 2012 4:05:51 PM (12 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r106161 r106167 1 2012-01-27 Michael Saboff <msaboff@apple.com> 2 3 StringProtoFuncToUpperCase should call StringImpl::upper similar to StringProtoToLowerCase 4 https://bugs.webkit.org/show_bug.cgi?id=76647 5 6 Reviewed by Geoffrey Garen. 7 8 Changed stringProtoFuncToUpperCase to call StringImpl::upper() is a manor similar 9 to stringProtoFuncToLowerCase(). Fixed StringImpl::upper() to handle the two 10 8 bit characters that when converted to upper case become 16 bit characters. 11 12 * runtime/StringPrototype.cpp: 13 (JSC::stringProtoFuncToLowerCase): Removed extra trailing whitespace. 14 (JSC::stringProtoFuncToUpperCase): 15 * wtf/text/StringImpl.cpp: 16 (WTF::StringImpl::upper): 17 1 18 2012-01-27 Hajime Morita <morrita@google.com> 2 19 -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r105698 r106167 1181 1181 return JSValue::encode(sVal); 1182 1182 1183 StringImpl* ourImpl = s.impl(); 1183 StringImpl* ourImpl = s.impl(); 1184 1184 RefPtr<StringImpl> lower = ourImpl->lower(); 1185 1185 if (ourImpl == lower.get()) … … 1200 1200 return JSValue::encode(sVal); 1201 1201 1202 const UChar* sData = s.characters(); 1203 Vector<UChar> buffer(sSize); 1204 1205 UChar ored = 0; 1206 for (int i = 0; i < sSize; i++) { 1207 UChar c = sData[i]; 1208 ored |= c; 1209 buffer[i] = toASCIIUpper(c); 1210 } 1211 if (!(ored & ~0x7f)) 1212 return JSValue::encode(jsString(exec, UString::adopt(buffer))); 1213 1214 bool error; 1215 int length = Unicode::toUpper(buffer.data(), sSize, sData, sSize, &error); 1216 if (error) { 1217 buffer.resize(length); 1218 length = Unicode::toUpper(buffer.data(), length, sData, sSize, &error); 1219 if (error) 1220 return JSValue::encode(sVal); 1221 } 1222 if (length == sSize) { 1223 if (memcmp(buffer.data(), sData, length * sizeof(UChar)) == 0) 1224 return JSValue::encode(sVal); 1225 } else 1226 buffer.resize(length); 1227 return JSValue::encode(jsString(exec, UString::adopt(buffer))); 1202 StringImpl* ourImpl = s.impl(); 1203 RefPtr<StringImpl> upper = ourImpl->upper(); 1204 if (ourImpl == upper.get()) 1205 return JSValue::encode(sVal); 1206 return JSValue::encode(jsString(exec, UString(upper.release()))); 1228 1207 } 1229 1208 -
trunk/Source/JavaScriptCore/wtf/text/StringImpl.cpp
r106019 r106167 364 364 int32_t length = m_length; 365 365 366 const UChar* source16; 367 366 368 if (is8Bit()) { 367 369 LChar* data8; … … 379 381 380 382 // Do a slower implementation for cases that include non-ASCII Latin-1 characters. 381 for (int32_t i = 0; i < length; i++) 382 data8[i] = static_cast<LChar>(Unicode::toUpper(m_data8[i])); 383 for (int32_t i = 0; i < length; i++) { 384 UChar upper = Unicode::toUpper(m_data8[i]); 385 if (UNLIKELY(upper > 0xff)) { 386 // Have a character that is 16bit when converted to uppercase. 387 source16 = characters(); 388 goto upconvert; 389 } 390 391 data8[i] = static_cast<LChar>(upper); 392 } 383 393 384 394 return newImpl.release(); 385 395 } 386 396 397 source16 = m_data16; 398 399 upconvert: 387 400 UChar* data16; 388 401 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16); … … 391 404 UChar ored = 0; 392 405 for (int i = 0; i < length; i++) { 393 UChar c = m_data16[i];406 UChar c = source16[i]; 394 407 ored |= c; 395 408 data16[i] = toASCIIUpper(c); … … 401 414 bool error; 402 415 newImpl = createUninitialized(m_length, data16); 403 int32_t realLength = Unicode::toUpper(data16, length, m_data16, m_length, &error);416 int32_t realLength = Unicode::toUpper(data16, length, source16, m_length, &error); 404 417 if (!error && realLength == length) 405 418 return newImpl; 406 419 newImpl = createUninitialized(realLength, data16); 407 Unicode::toUpper(data16, realLength, m_data16, m_length, &error);420 Unicode::toUpper(data16, realLength, source16, m_length, &error); 408 421 if (error) 409 422 return this;
Note: See TracChangeset
for help on using the changeset viewer.