2 ms·
I'd go for: Avoid creating objects that aren't needed, and avoid method calls. For the most part that's what his changes boils down to. In other words: Reduce
by vidarh 13y ago
I'd go for:
Avoid creating objects that aren't needed, and avoid method calls.
For the most part that's what his changes boils down to. In other words: Reduce complexity. It's very easy to cause Ruby code to blow up performance wise because you don't realize how many extra objects you create (arrays and hashes + lots of chaining or functional inspired method that returns copies instead of mutates == boom) or how many extra method calls you trigger behind the scenes.
- aaronblohowiak 13y agoMore generally, avoid duplicating effort: memoize as much as possible, including branching over invariants.