zvector/fate — Issue #1: Eliminate recursion in Pipeline{ƒ continuation}
Author: nickfargo
Created: 2011-11-03 19:56:22+00:00
State: open

For synchronous operations (i.e. non-Futures) in a Pipeline, continuations are currently facilitated by recursively calling the `continuation` function, passing it the result of the just-completed operation in the context of the next operation. As JS is not tail-call optimized, this yields an O(n) imposition on the stack.

Instead, a loop should be used for this purpose, replacing the context and arguments from the recursive approach with vars that get reassigned on each iteration. Avoiding recursion in this way would reduce the stack cost for any contiguous sequence of synchronous operations to O(1).