Skip to content
  • benjamin@webkit.org's avatar
    Optimize String.split() for 1 character separator · 114b51cf
    benjamin@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=83546
    
    Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-04-11
    Reviewed by Gavin Barraclough.
    
    This patch adds a serie of optimizations to make stringProtoFuncSplit() faster in the common case
    where the separator is a single character.
    
    The two main gains are:
    -Use of the find() function with a single character instead of doing a full string matching.
    -Use of WTF::find() instead of UString::find() to avoid branching on is8Bit() and have a simpler inline
     function.
    
    The code is also changed to avoid making unnecessary allocations by converting the 8bit string to 16bits.
    
    This makes String.split() faster by about 13% in that particular case.
    
    * runtime/StringPrototype.cpp:
    (JSC):
    (JSC::splitStringByOneCharacterImpl):
    (JSC::stringProtoFuncSplit):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113886 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    114b51cf