From: Nicolas Pitre Date: Wed, 25 Jun 2008 03:17:12 +0000 (-0400) Subject: optimize verify-pack a bit X-Git-Tag: v1.6.0-rc0~216 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=99093238bbf2cd886debf7bdb91478cb405ef66d;p=git.git optimize verify-pack a bit Using find_pack_entry_one() to get object offsets is rather suboptimal when nth_packed_object_offset() can be used directly. Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- diff --git a/cache.h b/cache.h index a9c14da7a..c8954ef15 100644 --- a/cache.h +++ b/cache.h @@ -712,6 +712,7 @@ extern void close_pack_windows(struct packed_git *); extern void unuse_pack(struct pack_window **); extern struct packed_git *add_packed_git(const char *, int, int); extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t); +extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t); extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *); extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *); extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep); diff --git a/pack-check.c b/pack-check.c index b99a9171c..d6dbd4b9d 100644 --- a/pack-check.c +++ b/pack-check.c @@ -67,9 +67,7 @@ static int verify_packfile(struct packed_git *p, entries[i].sha1 = nth_packed_object_sha1(p, i); if (!entries[i].sha1) die("internal error pack-check nth-packed-object"); - entries[i].offset = find_pack_entry_one(entries[i].sha1, p); - if (!entries[i].offset) - die("internal error pack-check find-pack-entry-one"); + entries[i].offset = nth_packed_object_offset(p, i); } qsort(entries, nr_objects, sizeof(*entries), compare_entries); diff --git a/sha1_file.c b/sha1_file.c index b2db549d8..e79b2c114 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1714,7 +1714,7 @@ const unsigned char *nth_packed_object_sha1(struct packed_git *p, } } -static off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n) +off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n) { const unsigned char *index = p->index_data; index += 4 * 256;