StylePropertySet::asText should use StringBuilder instead of adding bunch of string literals and String by operator+ and operator+=.
Created attachment 133446 [details] Cleanup
Committed r111845: <http://trac.webkit.org/changeset/111845>
Just came across your commit message: "Make StylePropertySet::asText more efficient by deploying StringBuilder; avoids heap churn by String::operator+ and String::operator+=." First of all this change is great and correct. For cases like this StringBuilder should be used (if we don't know before of many parts it consists, aka. how big the final string is). But "String a = stringB + "C" + "D" + stringC" doesn't involve any heap churns anymore, only String::operator+= is inefficient, String::operator+ uses magic, to avoid any immediate heap allocations, by figuring out the final buffer size before. So whenever you want to concat three strings (not necessarily of the same types, eg. a const char* with a String and an AtomicString), using String::operator+ is the easiest and most performant way. (Have a look at the StringAppend<> template stuff). Just wanted to let you know :-)
(In reply to comment #3) > Just came across your commit message: > "Make StylePropertySet::asText more efficient by deploying StringBuilder; avoids heap churn by String::operator+ and String::operator+=." > > First of all this change is great and correct. For cases like this StringBuilder should be used (if we don't know before of many parts it consists, aka. how big the final string is). > > But "String a = stringB + "C" + "D" + stringC" doesn't involve any heap churns anymore, only String::operator+= is inefficient, String::operator+ uses magic, to avoid any immediate heap allocations, by figuring out the final buffer size before. Okay, I wasn't sure if that optimization had been landed or not. Good to know it's in there :) Is it defined in WTFString.h?
(In reply to comment #4) > Okay, I wasn't sure if that optimization had been landed or not. Good to know it's in there :) Is it defined in WTFString.h? wtf/text/text/StringOperators.h and StringConcatenate.h contain the code.