2 ms·
> and taking a few seconds to comment that this is a low hanging fruit if i need it has helped future-me at least once. The problem with "fruit" like this is t
by yid 10y ago
> and taking a few seconds to comment that this is a low hanging fruit if i need it has helped future-me at least once.
The problem with "fruit" like this is that it depends heavily on the exact version of the JS runtime being used. If the next iteration of V8 introduces an automatic optimization or (worse) de-optimization for your low-hanging fruit, you're left with sometimes odd-looking code for a behavior that no longer exists.
As we've learned from the history of C++, if you depend on undefined/undocumented behavior quirks of a compiler or runtime, you're going to have a bad time. It's better to bump micro-optimizations like this down to a lower-level language. At best, you're buying a constant factor in whatever scaling curve you're trying to beat.
- Klathmon 10y agoI'm not talking about JIT tricks or JS engine quirks, but more like "Heads up, this function is O(n^2) because i'm lazy"