⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 101187 in webkit


Ignore:
Timestamp:
Nov 25, 2011, 10:15:20 PM (15 years ago)
Author:
msaboff@apple.com
Message:

String.prototype.toLower should be optimized for 8 bit strings
https://bugs.webkit.org/show_bug.cgi?id=73154

Changed stringProtoFuncToLowerCase to use StringImpl::lower() which has
been optimized for 8 bit strings.

This is worth ~7% to sunspider string.tagcloud.

Reviewed by Filip Pizlo.

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncToLowerCase):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r101186 r101187  
     12011-11-25  Michael Saboff  <msaboff@apple.com>
     2
     3        String.prototype.toLower should be optimized for 8 bit strings
     4        https://bugs.webkit.org/show_bug.cgi?id=73154
     5
     6        Changed stringProtoFuncToLowerCase to use StringImpl::lower() which has
     7        been optimized for 8 bit strings.
     8
     9        This is worth ~7% to sunspider string.tagcloud.
     10
     11        Reviewed by Filip Pizlo.
     12
     13        * runtime/StringPrototype.cpp:
     14        (JSC::stringProtoFuncToLowerCase):
     15
    1162011-11-25  Michael Saboff  <msaboff@apple.com>
    217
  • trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp

    r100314 r101187  
    11901190        return JSValue::encode(sVal);
    11911191
    1192     const UChar* sData = s.characters();
    1193     Vector<UChar> buffer(sSize);
    1194 
    1195     UChar ored = 0;
    1196     for (int i = 0; i < sSize; i++) {
    1197         UChar c = sData[i];
    1198         ored |= c;
    1199         buffer[i] = toASCIILower(c);
    1200     }
    1201     if (!(ored & ~0x7f))
    1202         return JSValue::encode(jsString(exec, UString::adopt(buffer)));
    1203 
    1204     bool error;
    1205     int length = Unicode::toLower(buffer.data(), sSize, sData, sSize, &error);
    1206     if (error) {
    1207         buffer.resize(length);
    1208         length = Unicode::toLower(buffer.data(), length, sData, sSize, &error);
    1209         if (error)
    1210             return JSValue::encode(sVal);
    1211     }
    1212     if (length == sSize) {
    1213         if (memcmp(buffer.data(), sData, length * sizeof(UChar)) == 0)
    1214             return JSValue::encode(sVal);
    1215     } else
    1216         buffer.resize(length);
    1217     return JSValue::encode(jsString(exec, UString::adopt(buffer)));
     1192    return JSValue::encode(jsString(exec, UString(s.impl()->lower())));
    12181193}
    12191194
Note: See TracChangeset for help on using the changeset viewer.