Skip to content
  • benjamin@webkit.org's avatar
    Improve charactersAreAllASCII() to compare multiple characters at a time · fe752ee2
    benjamin@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=74063
    
    Reviewed by Darin Adler.
    
    Source/JavaScriptCore:
    
    A new header ASCIIFastPath.h contains the functions related to
    the detection of ASCII by using machine words. Part of it comes from
    WebCore's TextCodecASCIIFastPath.h.
    
    The function charactersAreAllASCII() is moved to TextCodecASCIIFastPath.h
    and is implemented with computer word comparison.
    The gain over the previous implementation of charactersAreAllASCII() is of
    the order of how many comparison are avoided (4x, 8x, 16x depending on the
    format and the CPU type).
    
    * GNUmakefile.list.am:
    * JavaScriptCore.gypi:
    * JavaScriptCore.vcproj/WTF/WTF.vcproj:
    * JavaScriptCore.xcodeproj/project.pbxproj:
    * wtf/text/ASCIIFastPath.h: Added.
    (WTF::isAlignedToMachineWord):
    (WTF::alignToMachineWord):
    (WTF::isAllASCII):
    (WTF::charactersAreAllASCII):
    * wtf/text/WTFString.h:
    * wtf/wtf.pro:
    
    Source/JavaScriptGlue:
    
    Add forwarding header for ASCIIFastPath.h.
    
    * ForwardingHeaders/wtf/text/ASCIIFastPath.h: Added.
    
    Source/WebCore:
    
    Move some part of TextCodecASCIIFastPath.h to WTF in ASCIIFastPath.h.
    The function isAllASCII() is changed to the template version which now works
    with both LChar and UChar.
    
    * ForwardingHeaders/wtf/text/ASCIIFastPath.h: Added.
    * platform/text/TextCodecASCIIFastPath.h:
    (WebCore::copyASCIIMachineWord):
    * platform/text/TextCodecLatin1.cpp:
    (WebCore::TextCodecLatin1::decode):
    * platform/text/TextCodecUTF8.cpp:
    (WebCore::TextCodecUTF8::decode):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104127 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    fe752ee2