Bug 32151 - String::append(const String& str) check whether str.length() != 0
Summary: String::append(const String& str) check whether str.length() != 0
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Enhancement
Assignee: Nobody
Depends on:
Reported: 2009-12-04 05:08 PST by Zoltan Herczeg
Modified: 2009-12-04 12:01 PST (History)
2 users (show)

See Also:

(Platform) String append patch (1.75 KB, patch)
2009-12-04 05:37 PST, Zoltan Herczeg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zoltan Herczeg 2009-12-04 05:08:45 PST
In CachedScript.cpp:

const String& CachedScript::script()

    if (!m_script && m_data) {
        m_script = m_decoder->decode(m_data->data(), encodedSize());
        m_script += m_decoder->flush();
        setDecodedSize(m_script.length() * sizeof(UChar));

    return m_script;

m_decoder->flush() usually returns with an empty string. However, the append duplicates the original string even in this case. (The script can be half mbyte or more). This is an unnecessary allocation and copy.
Comment 1 Zoltan Herczeg 2009-12-04 05:37:07 PST
Created attachment 44309 [details]
(Platform) String append patch
Comment 2 WebKit Review Bot 2009-12-04 05:37:31 PST
style-queue ran check-webkit-style on attachment 44309 [details] without any errors.
Comment 3 WebKit Commit Bot 2009-12-04 12:01:27 PST
Comment on attachment 44309 [details]
(Platform) String append patch

Clearing flags on attachment: 44309

Committed r51705: <http://trac.webkit.org/changeset/51705>
Comment 4 WebKit Commit Bot 2009-12-04 12:01:36 PST
All reviewed patches have been landed.  Closing bug.