From d72308e01c5977177cda0aed06cfeee9192e1247 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Wed, 4 Apr 2007 16:49:04 -0400 Subject: clean up and optimize nth_packed_object_sha1() usage Let's avoid the open coded pack index reference in pack-object and use nth_packed_object_sha1() instead. This will help encapsulating index format differences in one place. And while at it there is no reason to copy SHA1's over and over while a direct pointer to it in the index will do just fine. Signed-off-by: Nicolas Pitre Acked-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- pack-check.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'pack-check.c') diff --git a/pack-check.c b/pack-check.c index d9883225e..f58083d11 100644 --- a/pack-check.c +++ b/pack-check.c @@ -42,13 +42,14 @@ static int verify_packfile(struct packed_git *p, */ nr_objects = num_packed_objects(p); for (i = 0, err = 0; i < nr_objects; i++) { - unsigned char sha1[20]; + const unsigned char *sha1; void *data; enum object_type type; unsigned long size; off_t offset; - if (nth_packed_object_sha1(p, i, sha1)) + sha1 = nth_packed_object_sha1(p, i); + if (!sha1) die("internal error pack-check nth-packed-object"); offset = find_pack_entry_one(sha1, p); if (!offset) @@ -82,14 +83,16 @@ static void show_pack_info(struct packed_git *p) memset(chain_histogram, 0, sizeof(chain_histogram)); for (i = 0; i < nr_objects; i++) { - unsigned char sha1[20], base_sha1[20]; + const unsigned char *sha1; + unsigned char base_sha1[20]; const char *type; unsigned long size; unsigned long store_size; off_t offset; unsigned int delta_chain_length; - if (nth_packed_object_sha1(p, i, sha1)) + sha1 = nth_packed_object_sha1(p, i); + if (!sha1) die("internal error pack-check nth-packed-object"); offset = find_pack_entry_one(sha1, p); if (!offset) -- cgit v1.2.1