[Webkit-unassigned] [Bug 63330] Concatenating wide strings and WTF::Strings using operator+ is suboptimal on MSVC

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jun 24 13:10:47 PDT 2011


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





--- Comment #4 from Nikolas Zimmermann <zimmermann at kde.org>  2011-06-24 13:10:47 PST ---
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #0)
> > > The following code:
> > > 
> > > String color("brown");
> > > String workEthic("lazy");
> > > String result = L"The quick " + color + L" fox jumped over the " + workEthic + L" dogs";
> > > 
> > > ...doesn't behave in an optimal way. The optimal behavior would be for the + expressions to build up a StringAppend object, and only to convert to a String at the very end. What actually happens is:
> > > 
> > > 1. L"The quick " is converted to a String
> > Sounds like the right StringTypeAdapter is missing.
> > Try adding one for your string type in JavaScriptCore/wtf/text/StringConcatenate.h, that will make the String conversion unncessary when invoking operator+.
> 
> There is already a StringTypeAdapter<const UChar*>. On Windows, UChar == wchar_t. So there's already the correct StringTypeAdapter for wide strings.

Oh okay, I overlooked that! but why is it converted to a string
The whole String result should be evaluated to:
String result = StringAppend<const UChar*, StringAppend<String, StringAppend<const UChar*, .... > > >.operator String();

It's intessting that your patch fixes it, I'd like Darin or Maciej to have a look here!

-- 
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