Re:Performance Improvement with the StringBuilder for C++
by AshleysBrain on Friday September 06, 2013 @10:28AM
(#6340582)
The article doesn't go in to much detail about why that class is really necessary. Couldn't you just loop the vector of strings, work out the total memory, then `reserve()` exactly the right amount? Then all the concatenations should be fast.
Alternatively `std::ostringstream` is specially designed for this type of task as well... how does it compare? Is it better/worse? Looks like reinventing the wheel to me.
Re:Performance Improvement with the StringBuilder for C++
by scast on Friday September 06, 2013 @01:52PM
(#6341685)
Somebody in the OP already commented about ostringstream and the article was updated accordingly. ostringstream is better, and I suposse more idiomatic.
Alternatively `std::ostringstream` is specially designed for this type of task as well... how does it compare? Is it better/worse? Looks like reinventing the wheel to me.