Turn O(n^2) reverse into O(n)

This patch improves `cabal update` performance by 10x(!) on my system.
Due to this issue, `cabal update` was using an extreme amount of CPU,
while it should be I/O-bound.  The reverse was taking 79s, now it
takes 0.01s.