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 <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nicolas Pitre committed
Jun 24, 2008 at 23:17 UTC
99093238bbf2cd886debf7bdb91478cb405ef66d
3 files changed
+3
-4
cache.h
+1
@@ -712,6 +712,7 @@ extern void close_pack_windows(struct packed_git *);
712
extern void unuse_pack(struct pack_window **);
713
extern struct packed_git *add_packed_git(const char *, int, int);
714
extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t);
715
+extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t);
716
extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
717
extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
718
extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
pack-check.c
+1
-3
@@ -67,9 +67,7 @@ static int verify_packfile(struct packed_git *p,
67
entries[i].sha1 = nth_packed_object_sha1(p, i);
68
if (!entries[i].sha1)
69
die("internal error pack-check nth-packed-object");
70
- entries[i].offset = find_pack_entry_one(entries[i].sha1, p);
71
- if (!entries[i].offset)
72
- die("internal error pack-check find-pack-entry-one");
70
+ entries[i].offset = nth_packed_object_offset(p, i);
71
}
72
qsort(entries, nr_objects, sizeof(*entries), compare_entries);
73
sha1_file.c
+1
-1
@@ -1714,7 +1714,7 @@ const unsigned char *nth_packed_object_sha1(struct packed_git *p,
1714
}
1715
}
1716
1717
-static off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n)
1717
+off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n)
1718
{
1719
const unsigned char *index = p->index_data;
1720
index += 4 * 256;