Skip to content

Commit

Permalink
find_pack_entry(): document last_found_pack
Browse files Browse the repository at this point in the history
Add a comment at the declaration of last_found_pack and where it is
used in find_pack_entry().  In the latter, separate the cases (1) to
make a place for the new comment and (2) to turn the success case into
affirmative logic.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Feb 24, 2014
1 parent ce37586 commit 1b1005d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ static struct cached_object empty_tree = {
0
};

/*
* A pointer to the last packed_git in which an object was found.
* When an object is sought, we look in this packfile first, because
* objects that are looked up at similar times are often in the same
* packfile as one another.
*/
static struct packed_git *last_found_pack;

static struct cached_object *find_cached_object(const unsigned char *sha1)
Expand Down Expand Up @@ -2460,11 +2466,13 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
return 1;

for (p = packed_git; p; p = p->next) {
if (p == last_found_pack || !fill_pack_entry(sha1, e, p))
continue;
if (p == last_found_pack)
continue; /* we already checked this one */

last_found_pack = p;
return 1;
if (fill_pack_entry(sha1, e, p)) {
last_found_pack = p;
return 1;
}
}
return 0;
}
Expand Down

0 comments on commit 1b1005d

Please sign in to comment.