4 ms·
Here's the easiest example I can come up with: // Optimized this code as it's a hotspot. Does <x> but quickly.
by falcolas 11y ago
Here's the easiest example I can come up with:
// Optimized this code as it's a hotspot. Does <x> but quickly.
- joshka 11y agohow is this better than: void DoActionOptimized() { ... }
- zachsnow 11y agoOptimized how? Faster? Less memory? Something more subtle?
- joshka 11y agoThat's what naming is for. MemoryOptimizedFoo, FastFoo, ...
- lomnakkus 11y agoIn fact you might also want the un-optimized code around and run the optimized version "against" the un-optimized version (in tests) to see if they actually do the same thing.
- codingdave 11y agoBecause at one point, the code was not optimized, so it already had a function name. Are you really going to rename all instances where that function is called so it is named based on a single commit, instead of its actual purpose?
- joshka 11y agoThere are many ways that are non breaking to implement this. I chose a particular one for example's sake. In reality, extracting an interface is a more valuable refactoring, and a likely valid one given that the optimization tradeoff is happening. So MemoryOptimizedFoo : IFoo, SpeedOptimizedFoo : IFoo...