Commit b0886a77 authored by beidson's avatar beidson

Reviewed by Adele and Adam

        Added an optimization to return early if there's no replacements to be made

        * platform/StringImpl.cpp:
        (WebCore::StringImpl::replace):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16080 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d6debfdb
2006-08-28 Brady Eidson <beidson@apple.com>
Reviewed by Adele and Adam
Added an optimization to return early if there's no replacements to be made
* platform/StringImpl.cpp:
(WebCore::StringImpl::replace):
2006-08-28 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed and landed by ap.
......
......@@ -773,6 +773,10 @@ StringImpl* StringImpl::replace(UChar pattern, const StringImpl* replacement)
++srcSegmentStart;
}
// If we have 0 matches, we don't have to do any more work
if (!matchCount)
return this;
// Create the new StringImpl;
StringImpl* dst = new StringImpl();
dst->m_length = m_length - matchCount + (matchCount * repStrLength);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment