> > The most complex methods (and slowest) here are "up" and "down".
> > Breaking the internals down into multiple lines rather than just the
> > @prev/@post pair, or somehow keeping track of the newlines would help
> > with the speed of up/down, but I got lazy.  =)
>
> These are way too slow.  It looks O(n**2).  You should look to see
> what happens when you double the size.  I think you might have hit an
> Array COW (copy-on-write) performance/memory bug(/leak?).  I've seen
> plenty of them.
>
> Why not use the deferred "sifting" like you do for left/right instead?
>  This would avoid the problem.

Ten minutes after I posted my solution, I asked myself the same thing.  =)

I'll try a rewrite if I get a chance, and look into your other comments as well.