Use a FIFO queue of RevCommit during reset rather than sorting by date
We really don't care about preserving commit time order during the
walk from the roots backwards to execute a reset. Performing a sort
during insertion into the queue only wastes CPU time. Using a FIFO
queue (or even a LIFO queue) makes this process faster.
I'm making the FIFO queue public as there are many algorithms that
we need to implement which will benefit from having a FIFO queue.
The FIFO queue uses a linked list of blocks, to make it cheap to add
additional memory as necessary but yet ammortize the cost of the
recording overheads imposed by the queue to almost 0. With a block
size of 256 we get an overhead of ~4.125 bytes per commit, with the
bulk of that 4 bytes going to the commit reference itself in the
block's commit array.
We don't bother to clear references after we pop them from the queue.
This is because a queue is meant to be used with a single RevWalk
instance and the RevCommits are pooled by strong references inside of
the RevWalk. Until the RevWalk goes away those commits will be
strongly held anyway, so clearing our arrays is a waste of CPU time
and memory bandwidth.
We allow blocks to be moved between two FIFORevQueues as some
uses will be doing exactly that; shuffling commits from one queue
into another queue. Sharing a single free list between them will
allow emptied blocks to migrate from the one queue to the other,
with only one additional block necessary as temporary working space.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>