[Webkit-unassigned] [Bug 63330] Concatenating string literals and WTF::Strings using operator+ is suboptimal

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


https://bugs.webkit.org/show_bug.cgi?id=63330


Darin Adler <darin at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #98746|review?                     |review+
               Flag|                            |




--- Comment #12 from Darin Adler <darin at apple.com>  2011-06-27 11:55:38 PST ---
(From update of attachment 98746)
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.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list