[webkit-reviews] review granted: [Bug 63330] Concatenating string literals and WTF::Strings using operator+ is suboptimal : [Attachment 98746] Make concatenating string literals and WTF::Strings more efficient

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jun 27 11:55:38 PDT 2011


Darin Adler <darin at apple.com> has granted Adam Roben (:aroben)
<aroben at apple.com>'s request for review:
Bug 63330: Concatenating string literals and WTF::Strings using operator+ is
suboptimal
https://bugs.webkit.org/show_bug.cgi?id=63330

Attachment 98746: Make concatenating string literals and WTF::Strings more
efficient
https://bugs.webkit.org/attachment.cgi?id=98746&action=review

------- Additional Comments from Darin Adler <darin at apple.com>
View in context: https://bugs.webkit.org/attachment.cgi?id=98746&action=review

> Source/JavaScriptCore/wtf/text/StringOperators.h:109
>  template<typename U, typename V, typename W>
> -StringAppend<U, StringAppend<V, W> > operator+(U string1, const
StringAppend<V, W>& string2)
> +StringAppend<StringAppend<U, V>, W> operator+(const StringAppend<U, V>&
string1, W string2)
>  {
> -    return StringAppend<U, StringAppend<V, W> >(string1, string2);
> +    return StringAppend<StringAppend<U, V>, W>(string1, string2);
>  }

I think the reason this is correct is that the + operator is left-associative.
Ideally we should make unit test cases for this that somehow check how many
string objects are allocated. I would want to use tests to prove that this does
not adversely affect expressions like these:

    a + (b + c)
    (a + b) + (c + d)

with various types of arguments.


More information about the webkit-reviews mailing list