Skip to content

Commit 1b1005d

Browse files
mhaggergitster
authored andcommitted
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 <[email protected]> Reviewed-by: Nicolas Pitre <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ce37586 commit 1b1005d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

sha1_file.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ static struct cached_object empty_tree = {
6060
0
6161
};
6262

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+
*/
6369
static struct packed_git *last_found_pack;
6470

6571
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)
24602466
return 1;
24612467

24622468
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 */
24652471

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+
}
24682476
}
24692477
return 0;
24702478
}

0 commit comments

Comments
 (0)