{"thread":{"id":"14134","subject":"[PATCH 1/4] optimize verify-pack a bit","startedAt":"2008-06-25T03:17:12Z","lastAt":"2008-06-25T03:17:12Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"81040","messageId":"alpine.LFD.1.10.0806242315570.2979@xanadu.home","threadId":"14134","inReplyTo":null,"subject":"[PATCH 1/4] optimize verify-pack a bit","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-06-25T03:17:12Z","receivedAt":"2008-06-25T03:17:12Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"\nUsing find_pack_entry_one() to get object offsets is rather suboptimal\nwhen nth_packed_object_offset() can be used directly.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n cache.h      |    1 +\n pack-check.c |    4 +---\n sha1_file.c  |    2 +-\n 3 files changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex a68866c..16222a3 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -711,6 +711,7 @@ extern void close_pack_windows(struct packed_git *);\n extern void unuse_pack(struct pack_window **);\n extern struct packed_git *add_packed_git(const char *, int, int);\n extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t);\n+extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t);\n extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);\n extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);\n extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\ndiff --git a/pack-check.c b/pack-check.c\nindex b99a917..d6dbd4b 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -67,9 +67,7 @@ static int verify_packfile(struct packed_git *p,\n \t\tentries[i].sha1 = nth_packed_object_sha1(p, i);\n \t\tif (!entries[i].sha1)\n \t\t\tdie(\"internal error pack-check nth-packed-object\");\n-\t\tentries[i].offset = find_pack_entry_one(entries[i].sha1, p);\n-\t\tif (!entries[i].offset)\n-\t\t\tdie(\"internal error pack-check find-pack-entry-one\");\n+\t\tentries[i].offset = nth_packed_object_offset(p, i);\n \t}\n \tqsort(entries, nr_objects, sizeof(*entries), compare_entries);\n \ndiff --git a/sha1_file.c b/sha1_file.c\nindex 9330bc4..a92f023 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1708,7 +1708,7 @@ const unsigned char *nth_packed_object_sha1(struct packed_git *p,\n \t}\n }\n \n-static off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n)\n+off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n)\n {\n \tconst unsigned char *index = p->index_data;\n \tindex += 4 * 256;\n-- \n1.5.6.56.g29b0d\n"}]}