Skip to content

Commit

Permalink
optimize verify-pack a bit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nicolas Pitre authored and Junio C Hamano committed Jun 25, 2008
1 parent 8e21d63 commit 9909323
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions pack-check.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9909323

Please sign in to comment.