scala/scala — pull request #2688 by yllan (2013-06-27 14:41:46+00:00)
Title: SI-7614 Minimize the times of evaluation f in TraversableOnce.maxBy/minBy

In the previous implementation, maxBy/minBy will evaluate most of its elements
with f twice to get the ordering. That results (2n - 2) evaluations of f.

I save both the element and result of evaluation to a tuple so that it doesn't
need to re-evaluate f on next comparison. Thus only n evaluations of f, that is
the optimal.