andrewplummer/Sugar — pull request #274 by alFReD-NSH (2013-02-20 09:24:44+00:00)
Title: Optimize multiMatch by evaluating the matcher once

Note that the getMatcher should be called lazily in the iterator callback
function or emptyArray.find(..) will be slower.

Benchmark: https://gist.github.com/alFReD-NSH/4994209

Before:

emptyArray.Find(emptyFunction) x 982,473 ops/sec ±13.16% (38 runs sampled)
arrayWith500.Find(emptyFunction) x 733 ops/sec ±5.33% (50 runs sampled)
After:

emptyArray.Find(emptyFunction) x 998,526 ops/sec ±0.64% (54 runs sampled)
arrayWith500.Find(emptyFunction) x 1,577 ops/sec ±14.83% (28 runs sampled)