News for hackers. Stuff that matters.
Re:Performance Improvement with the StringBuilder for C++ by twoodfin on Friday September 06, 2013 @10:24AM (#6340564)
I write enough performance-sensitive code that I've gotten into the habit of calling .reserve() with a generous final size estimate immediately after constructing a string or vector (assuming I'm not using a constructor that sizes it appropriately to begin with). It's hard to overestimate just how expensive repeated calls to malloc()/free() are.

In the innermost of inner loops, I've been known to use a static string or vector to avoid repeated allocation entirely. Only in single-threaded code of course!

There are no comments on this comment yet.