Reviewed by Darin.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Sep 2004 00:16:34 +0000 (00:16 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Sep 2004 00:16:34 +0000 (00:16 +0000)
commit3290b23fe95a6c0c6b7deef2ea1d3d090d419690
treebfcebc7ad95da1272ce25527bd0dcc7b5c9ecfb6
parent1f453b6940835fd89e4a363b45d227e5cb91466b
    Reviewed by Darin.

<rdar://problem/3794735> Gmail- sending a very long message with Safari is so slow it seems like a hang

* kjs/string_object.cpp:
        (StringProtoFuncImp::call): Replaced implementation of replace()
method with function below...
(replace): In order to avoid excessive allocation and copying,
figure out the ranges of the original string and replacement
strings to be assembled, instead of constantly creating new
strings at each substitution. The old behavior is basically O(N^2)
for a global replace on a pattern that matches many places in the
string.
        (regExpIsGlobal): Helper function for the above.
        (expandSourceRanges): ditto
        (pushSourceRange): ditto
        (expandReplacements): ditto
        (pushReplacement): ditto
        * kjs/ustring.cpp:
(KJS::UString::spliceSubstringsWithSeparators): New method that
pieces together substring ranges of this string together with
specified separators, all at one go.
        * kjs/ustring.h:
        (KJS::UString::Range::Range): Added new helper class to represent
substring choices.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7564 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JavaScriptCore/ChangeLog
JavaScriptCore/kjs/string_object.cpp
JavaScriptCore/kjs/ustring.cpp
JavaScriptCore/kjs/ustring.h