The devil is in details. And also in unclear explanations!
Normal #min and #max methods don't allocate other arrays, the problem is that is idiomatic in Ruby to calculate the max/min of 2 variables by wrapping them in a array literal and calling the respective method, instead of doing a if or ternary. This of course has much bigger overhead, including an useless array allocation.
The change is essentially just rewriting these occurrences in the bytecode compiler to the simple version.
5
u/NeuroXc Dec 25 '16
Wait a second...
Why would you need to ever create a temporary array to find the max or min in an array?