Changeset 153007 in webkit
- Timestamp:
- Jul 22, 2013, 3:29:03 PM (12 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r152973 r153007 1 2013-07-22 Benjamin Poulain <benjamin@webkit.org> 2 3 String::lower() - Skip to slow path on the first failure 4 https://bugs.webkit.org/show_bug.cgi?id=118885 5 6 Reviewed by Andreas Kling. 7 8 In the 8 bits case, we don't need to know the state of the full string before changing characters 9 to their lowercase variant. 10 Just fail immediately and start transforming characters from the point of failure. 11 12 This avoid reading the string twice when the uppercase character is not at the end of the string. 13 14 * wtf/text/StringImpl.cpp: 15 (WTF::StringImpl::lower): 16 1 17 2013-07-22 Brent Fulgham <bfulgham@apple.com> 2 18 -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r152883 r153007 393 393 // First scan the string for uppercase and non-ASCII characters: 394 394 bool noUpper = true; 395 unsigned ored = 0;396 395 if (is8Bit()) { 396 unsigned failingIndex; 397 397 for (unsigned i = 0; i < m_length; ++i) { 398 398 LChar character = m_data8[i]; 399 if (UNLIKELY( isASCIIUpper(character)))400 noUpper = false;401 ored |= character;402 }403 // Nothing to do if the string is all ASCII with no uppercase.404 if (noUpper && !(ored & ~0x7F))405 return this; 406 399 if (UNLIKELY((character & ~0x7F) || isASCIIUpper(character))) { 400 failingIndex = i; 401 goto SlowPath8bitLower; 402 } 403 } 404 return this; 405 406 SlowPath8bitLower: 407 407 LChar* data8; 408 408 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data8); 409 409 410 if (!(ored & ~0x7F)) {411 for (unsigned i = 0; i < m_length; ++i)412 data8[i] = toASCIILower(m_data8[i]); 413 414 return newImpl.release();415 }416 417 // Do a slower implementation for cases that include non-ASCII Latin-1 characters.418 for (unsigned i = 0; i < m_length; ++i)419 data8[i] = static_cast<LChar>(Unicode::toLower(m_data8[i]));410 for (unsigned i = 0; i < failingIndex; ++i) 411 data8[i] = m_data8[i]; 412 413 for (unsigned i = failingIndex; i < m_length; ++i) { 414 LChar character = m_data8[i]; 415 if (!(character & ~0x7F)) 416 data8[i] = toASCIILower(character); 417 else 418 data8[i] = static_cast<LChar>(Unicode::toLower(character)); 419 } 420 420 421 421 return newImpl.release(); 422 422 } 423 unsigned ored = 0; 423 424 424 425 for (unsigned i = 0; i < m_length; ++i) {
Note:
See TracChangeset
for help on using the changeset viewer.