cujojs / when

A solid, fast Promises/A+ and when() implementation, plus other async goodies.
Other
3.44k stars 396 forks source link

Improve any and some perf #399

Closed briancavalier closed 9 years ago

briancavalier commented 9 years ago

They now use similar patterns to _traverse. Also: fix _traverse fast-path on first rejection. Simplify resolveAndObserveRemaining to visitRemaining and expose as private API to allow other array combinators to take advantage of it.

briancavalier commented 9 years ago

The perf increases for any and some grow as array size grows. Perhaps more importantly, though, for any, all and map, this improves the early bailout performance. For example, if the first item in an array passed to all is a rejection, this will bail out of the main algorithm and use a fast path to mark any remaining potentially rejected promises as "handled". It also fixes a regression in 3.6.0 that prevented early bailout entirely in all and map.