summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-02-21 16:32:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-02-24 17:09:56 (GMT)
commit1b1005d1b5da02483a9d275f5df522d4d298cc36 (patch)
tree7206da556a0176c09f593aac8678f6c57b38529c /sha1_file.c
parentce375864759f14498126e1f5e630058b6656d187 (diff)
downloadgit-1b1005d1b5da02483a9d275f5df522d4d298cc36.zip
git-1b1005d1b5da02483a9d275f5df522d4d298cc36.tar.gz
git-1b1005d1b5da02483a9d275f5df522d4d298cc36.tar.bz2
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>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 6e8c05d..0910939 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -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)
@@ -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;
}