JavaScriptCore:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Sep 2006 21:07:39 +0000 (21:07 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Sep 2006 21:07:39 +0000 (21:07 +0000)
commitcf1c90ad5bf6ba422286de620121f67abfe19948
tree46c04ee8448c1daa39df2265701c0cb8d854b27b
parent7b38805c1b5b8fcf1fae2a5d0816bff224f00051
JavaScriptCore:

        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: https://svn.webkit.org/repository/webkit/trunk@16622 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JavaScriptCore/ChangeLog
JavaScriptCore/wtf/Vector.h
WebCore/ChangeLog
WebCore/platform/PlatformString.h
WebCore/platform/StreamingTextDecoder.cpp
WebCore/platform/StreamingTextDecoder.h
WebCore/platform/StreamingTextDecoderICU.cpp
WebCore/platform/String.cpp
WebCore/platform/StringImpl.cpp
WebCore/platform/StringImpl.h
WebCore/platform/mac/StreamingTextDecoderMac.cpp