[Webkit-unassigned] [Bug 10818] New: String::append does 2 full copies instead of 1 (or zero!)

bugzilla-daemon at opendarwin.org bugzilla-daemon at opendarwin.org
Mon Sep 11 19:38:35 PDT 2006


http://bugzilla.opendarwin.org/show_bug.cgi?id=10818

           Summary: String::append does 2 full copies instead of 1 (or
                    zero!)
           Product: WebKit
           Version: 420+ (nightly)
          Platform: Macintosh
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Platform
        AssignedTo: webkit-unassigned at opendarwin.org
        ReportedBy: macdome at opendarwin.org


I'm surprised this hasn't been noticed before.

It seems String::append is about as inefficient as possible.

String::append results in 2 full copies of the string being made.  That's one
more than necessary.  If String was even smarter, it would pre-allocate a
certain amount of extra space, resulting in 0 necessary copies.

Safari hung for several minutes loading a 30MB SVG file.  Pretty much all of
that time was spent copying strings for String::append:


        0.0%    100.0%  WebCore WebCore::Frame::addData(char const*, int)       
        0.0%    100.0%  WebCore WebCore::Frame::write(char const*, int) 
        0.0%    100.0%  WebCore WebCore::Decoder::decode(char const*, unsigned
long)    
        0.0%    100.0%  WebCore WebCore::TextDecoder::decode(char const*,
unsigned long, bool)  
        0.0%    100.0%  WebCore WebCore::TextDecoder::checkForBOM(char const*,
unsigned long, bool)     
        0.6%    100.0%  WebCore WebCore::TextCodecICU::decode(char const*,
unsigned long, bool) 
        0.5%    99.4%   WebCore
WebCore::TextCodec::appendOmittingBOM(WebCore::String&, unsigned short const*,
unsigned long)   
        0.0%    98.8%   WebCore WebCore::String::append(WebCore::String const&) 
        0.0%    49.8%   WebCore WebCore::StringImpl::copy() const       
        48.9%   48.9%   WebCore WebCore::StringImpl::append(WebCore::StringImpl
const*)


-- 
Configure bugmail: http://bugzilla.opendarwin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list