Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I couldn't find a reason for this pattern to call a method to get a similar proc every time. It does incur an extra method call, and a Proc object allocation. In addition, in the case of `collection_converter`, the relatively complex code can be replaced by a simpler and faster `map`. Map is preferable over shifting objects into a new Array, because it allows Ruby to directly allocate an Array of the right size rather than to have to potentially resize it multiple times. This isn't a big gain, but I think it makes the code easier to read anyway. Before: ``` Calculating ------------------------------------- alba 801.321 (± 0.6%) i/s (1.25 ms/i) - 4.080k in 5.091760s Calculating ------------------------------------- alba 826.321k memsize ( 0.000 retained) 9.908k objects ( 0.000 retained) 6.000 strings ( 0.000 retained) ``` After: ``` Calculating ------------------------------------- alba 830.039 (± 0.8%) i/s (1.20 ms/i) - 4.182k in 5.038669s Calculating ------------------------------------- alba 818.241k memsize ( 0.000 retained) 9.807k objects ( 0.000 retained) 6.000 strings ( 0.000 retained) ```
- Loading branch information