[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 11:20:51 PDT 2011


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





--- Comment #2 from Nikolas Zimmermann <zimmermann at kde.org>  2011-06-24 11:20:51 PST ---
(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+.

> 2. (String(L"The quick ") + color) is evaluated, resulting in a StringAppend object
> 3. StringAppend::operator String() is called
> 4. (String(L"The quick brown") + L" fox jumped over the ") is evaluated, resulting in a StringAppend object
> 5. StringAppend::operator String() is called
> 
> ...and so on.
> 
> You can see that each concatenation is being converted to a String before the next concatenation occurs. It also shouldn't be necessary for the first wide string to be converted to a String.
That's stupid... Is this fixed when introducing the right StringTypeAdapter for wchar?

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