aboutsummaryrefslogtreecommitdiff
path: root/builtin-describe.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2008-02-24 03:07:22 -0500
committerJunio C Hamano <gitster@pobox.com>2008-02-24 10:01:24 -0800
commit0ae91be0e1fac3ff31675f0ec2c7ebf2bb5c1be6 (patch)
treec5a7cfabba9a8498e8dd168dd7812869c8f82242 /builtin-describe.c
parentdc31cd8fcc20d95a80da5ebe6feaab01539ebe4c (diff)
downloadgit-0ae91be0e1fac3ff31675f0ec2c7ebf2bb5c1be6.tar.gz
git-0ae91be0e1fac3ff31675f0ec2c7ebf2bb5c1be6.tar.xz
Optimize peel_ref for the current ref of a for_each_ref callback
Currently the only caller of peel_ref is show-ref, which is using this function to show the peeled tag information if it is available from an existing packed-refs file. The call happens during the for_each_ref callback function, so we have the proper struct ref_list already on the call stack but it is not easily available to return the peeled information to the caller. We now save the current struct ref_list item before calling back into the callback function so that future calls to peel_ref from within the callback function can quickly access the current ref. Doing so will save us an lstat() per ref processed as we no longer have to check the filesystem to see if the ref exists as a loose file or is packed. This current ref caching also saves a linear scan of the cached packed refs list. As a micro-optimization we test the address of the passed ref name against the current_ref->name before we go into the much more costly strcmp(). Nearly any caller of peel_ref will be passing us the same string do_for_each_ref passed them, which is current_ref->name. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-describe.c')
0 files changed, 0 insertions, 0 deletions