Hacker News new | ask | show | jobs
by jayvanguard 4212 days ago
I like the term micro-optimization. I wouldn't use them regularly in my code, maybe just in tight loop or something, but they aren't too invasive and can actually flag the code for future maintainers.

In fact, I'd consider adding a little "// micro-optmized" comment at the end of one of these to communicate to future developers that this mildly odd line is a useful but non-essential little optimization. So feel free to change it but you'll probably want to read up a little or do a quick benchmark before you do that.

1 comments

The ones described in this article are ones that shouldn't necessarily be constrained to tight loops if you're looking for maximum benefit. Because their real gain isn't saving CPU cycles, it's reducing load on the memory manager. There's definitely still a diminishing returns situation, but the returns may not diminish as quickly since a memory allocation done by one spot in the code has the ability to impact performance virtually anywhere else when you're working in a garbage-collected language.