Skip to content
  • darin's avatar
    JavaScriptCore: · 6138a1eb
    darin authored
            Reviewed by Alice.
    
            - support for change that should fix <rdar://problem/4733044>
              REGRESSION: XML iBench shows 10% perf. regression (copying
              strings while decoding)
    
            * wtf/Vector.h: Changed VectorBuffer so that the general case
            contains an instance of the 0 case, since deriving from it
            was violating the Liskov Substitution Principle.
            (WTF::VectorBuffer::releaseBuffer): Added. Releases the buffer so it can
            be adopted by another data structure that uses the FastMalloc.h allocator.
            Returns 0 if the internal buffer was being used.
            (WTF::Vector::releaseBuffer): Added. Releases the buffer as above or creates
            a new one in the case where the internal buffer was being used.
    
    WebCore:
    
            Reviewed by Alice.
    
            - change that should fix <rdar://problem/4733044> REGRESSION: XML iBench shows
              10% perf. regression (copying strings while decoding)
    
            Use Vector<UChar> instead of String when building up the decoded string in
            the ICU and Mac decoders. Using String leads to O(n^2) behavior because
            String grows the buffer every single time that append is called. Using
            Vector::append instead of String::append also avoids constructing a string
            each time just to append and a questionable copy that is done inside the
            String::append function which also contributed to the slowness.
    
            * platform/PlatformString.h:
            * platform/String.cpp: (WebCore::String::adopt): Added. Makes a String from a
            Vector<UChar>, adopting the buffer from the vector to avoid copying and memory
            allocation.
            * platform/StringImpl.h:
            * platform/StringImpl.cpp: (WebCore::StringImpl::adopt): Ditto.
    
            * platform/StreamingTextDecoder.h:
            * platform/StreamingTextDecoder.cpp: (WebCore::TextCodec::appendOmittingBOM):
            Change to use a Vector<UChar> instead of a String, since vectors have better
            resizing performance (they store a separate capacity).
    
            * platform/StreamingTextDecoderICU.cpp: (WebCore::TextCodecICU::decode):
            * platform/mac/StreamingTextDecoderMac.cpp: (WebCore::TextCodecMac::decode):
            Change to use Vector<UChar> instead of String and then create a string at
            the end of the process using the new adopt function.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16622 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    6138a1eb