Changeset 37056 in webkit
- Timestamp:
- Sep 29, 2008 1:20:37 AM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r37055 r37056 1 2008-09-29 Mark Rowe <mrowe@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Apply the ASCII fast path optimization from StringImpl::lower to StringImpl::upper. 6 In the few places that we call .upper() in WebCore the strings represent things like 7 tag and attribute names, which are nearly always going to be ASCII. 8 9 * platform/text/StringImpl.cpp: 10 (WebCore::StringImpl::lower): If we have to resize the buffer, be sure to pass the new length 11 in to Unicode::toLower the second time. 12 (WebCore::StringImpl::upper): 13 1 14 2008-09-28 Mark Rowe <mrowe@apple.com> 2 15 -
trunk/WebCore/platform/text/StringImpl.cpp
r36073 r37056 362 362 return adopt(data); 363 363 data.resize(realLength); 364 Unicode::toLower(data.characters(), length, m_data, m_length, &error);364 Unicode::toLower(data.characters(), realLength, m_data, m_length, &error); 365 365 if (error) 366 366 return this; … … 370 370 PassRefPtr<StringImpl> StringImpl::upper() 371 371 { 372 StringBuffer data(m_length); 373 int32_t length = m_length; 374 375 // Do a faster loop for the case where all the characters are ASCII. 376 UChar ored = 0; 377 for (int i = 0; i < length; i++) { 378 UChar c = m_data[i]; 379 ored |= c; 380 data[i] = toASCIIUpper(c); 381 } 382 if (!(ored & ~0x7F)) 383 return adopt(data); 384 385 // Do a slower implementation for cases that include non-ASCII characters. 372 386 bool error; 373 int32_t length = Unicode::toUpper(0, 0, m_data, m_length, &error); 374 StringBuffer data(length); 375 Unicode::toUpper(data.characters(), length, m_data, m_length, &error); 387 int32_t realLength = Unicode::toUpper(data.characters(), length, m_data, m_length, &error); 388 if (!error && realLength == length) 389 return adopt(data); 390 data.resize(realLength); 391 Unicode::toUpper(data.characters(), realLength, m_data, m_length, &error); 376 392 if (error) 377 393 return this;
Note: See TracChangeset
for help on using the changeset viewer.