Re:Performance Matters
by anaphor on Monday August 19, 2019 @02:03PM
(#20740112)
Basically it can be summed up to "don't optimize until you've identified the critical paths"
[ Parent
| on HN ]
That’s oversimplifying it. Knuth was writing about micro-optimizations, like writing a section of code in assembly language to shave off some milliseconds from a critical section of code.
What many people today mean by optimization is a far cry from that.
Here’s a real-life example. Some code was super-slow and nobody could figure out why. It took only a minute to see the code was passing a string (in C++) by value, causing unnecessary copy construction and destruction (in a tight loop, to boot).
Writing that code by passing a const reference in the first place is Good Coding 101, but many people might consider that “premature optimization”.