5 ms·
“Avoid premature optimization” means to do the cleanest/clearest thing now, and only optimize later when you have the full picture. Arguably, that advice doesn’
by codeflo 4y ago
“Avoid premature optimization” means to do the cleanest/clearest thing now, and only optimize later when you have the full picture. Arguably, that advice doesn’t apply to standard library functions anyway, at least not to the same extent. But if it did: How is adding a new, “bad” implementation any clearer than simply calling the already existing optimized one that the GP linked to?
- philosopher1234 4y agoYou should optimize when it’s net useful, not just because you know how. Making a random function faster and harder to maintain is bad engineering if the speed isn’t useful.
- adwn 4y ago> Making a random function faster and harder to maintain is bad engineering if the speed isn’t useful. 1) It's not some random function, it's part of the standard library. 2) Three-way string compares are far from uncommon, and string comparisons are relatively expensive. Therefore, a speedup would be useful. Optimizing this function would not count as "premature".
- codeflo 4y agoAgain: How is adding a new, “bad” implementation any easier to maintain than simply calling the already existing optimized one that the GP linked to?