Watch out for sprintf()!

I was looking at some code the other day that does string concatenation with StringCchPrintf(“%s%s”).  I can imagine how this would have near optimal performance, and a hopeful developer could easily assume that in fact it has been tuned for this kind of concatenation.  But measuring tells all.  Three trivial implementations of concat using strsafe.h:void…

0

Performance work is slippery

… like a water snake.  Which is why we measure, measure and measure again.  Even the most obvious rule of thumb can be wrong.  I was optimizing some string parsing code (which is almost always ripe for optimization), and trying to reduce the cost of traversing a string.  When iterating over the elements of an…

1