find_pack_entry(): document last_found_pack

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>

Michael Haggerty committed Feb 21, 2014 at 17:32 UTC 1b1005d1b5da02483a9d275f5df522d4d298cc36
1 file changed +12 -4
sha1_file.c
+12 -4
@@ -60,6 +60,12 @@ static struct cached_object empty_tree = {
60 0
61 };
62
63 +/*
64 + * A pointer to the last packed_git in which an object was found.
65 + * When an object is sought, we look in this packfile first, because
66 + * objects that are looked up at similar times are often in the same
67 + * packfile as one another.
68 + */
69 static struct packed_git *last_found_pack;
70
71 static struct cached_object *find_cached_object(const unsigned char *sha1)
@@ -2460,11 +2466,13 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
2466 return 1;
2467
2468 for (p = packed_git; p; p = p->next) {
2463 - if (p == last_found_pack || !fill_pack_entry(sha1, e, p))
2464 - continue;
2469 + if (p == last_found_pack)
2470 + continue; /* we already checked this one */
2471
2466 - last_found_pack = p;
2467 - return 1;
2472 + if (fill_pack_entry(sha1, e, p)) {
2473 + last_found_pack = p;
2474 + return 1;
2475 + }
2476 }
2477 return 0;
2478 }