summaryrefslogtreecommitdiff
path: root/t/t4018
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2014-07-14 01:42:50 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-07-15 11:02:53 -0700
commit6d63baa47883315033474fc06196330e3a5ca4e0 (patch)
tree24fc3be4034fa1398c6a16c59c78a371b3893e2f /t/t4018
parentMerge branch 'maint' (diff)
downloadtgif-6d63baa47883315033474fc06196330e3a5ca4e0.tar.xz
prio-queue: factor out compare and swap operations
When manipulating the priority queue's heap, we frequently have to compare and swap heap entries. As we are storing only void pointers right now, this is quite easy to do inline in a few lines. However, when we start using a more complicated heap entry in a future patch, that will get longer. Factoring out these operations lets us make future changes in one place. It also makes the code a little shorter and more readable. Note that we actually accept indices into the queue array instead of pointers. This is slightly less flexible than passing pointers-to-pointers (we could not swap items from unrelated arrays, but we would not want to), but will make further refactoring simpler (and lets us avoid repeating "queue->array" at each callsite, which led to some long lines). And finally, note that we are cleaning up an accidental use of a "struct commit" pointer to hold a temporary entry during swap. Even though we currently only use this code for commits, it is supposed to be type-agnostic. In practice this didn't matter anyway because we never dereferenced the commit pointer (and on most systems, the pointer values themselves are interchangeable between types). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4018')
0 files changed, 0 insertions, 0 deletions