Skip to content
  • benjamin@webkit.org's avatar
    Generalize the single character optimization of r114072 · 3cdab957
    benjamin@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=83961
    
    Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-04-24
    Reviewed by Eric Seidel.
    
    Source/JavaScriptCore: 
    
    Use the regular String::find(StringImpl*) in all cases now that it has been made faster.
    
    * runtime/StringPrototype.cpp:
    (JSC::replaceUsingStringSearch):
    
    Source/WTF: 
    
    This patch makes some improvment over String::find() in the case of lookup for a single
    character.
    
    The two function find(UChar|LChar) are replaced by a template.
    
    The case of searching a UChar in a 8bit string has a shortcut if the UChar cannot
    possibly match any character in the range of the type LChar.
    
    The slow case StringImpl::find(StringImpl*) is modified to
    -Do not allocate in the fast case if only one string is 8bit.
    -Use the shortcut for searching UChar in LChar.
    
    This speed up the function by about 7% when avoiding string conversion.
    
    * wtf/text/StringImpl.cpp:
    (WTF::StringImpl::find):
    * wtf/text/StringImpl.h:
    (StringImpl):
    (WTF):
    (WTF::find):
    (WTF::StringImpl::find):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@115132 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    3cdab957