* [PATCH 1/4] optimize verify-pack a bit
@ 2008-06-25 3:17 Nicolas Pitre
0 siblings, 0 replies; only message in thread
From: Nicolas Pitre @ 2008-06-25 3:17 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
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>
---
cache.h | 1 +
pack-check.c | 4 +---
sha1_file.c | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/cache.h b/cache.h
index a68866c..16222a3 100644
--- a/cache.h
+++ b/cache.h
@@ -711,6 +711,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 b99a917..d6dbd4b 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 9330bc4..a92f023 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1708,7 +1708,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;
--
1.5.6.56.g29b0d
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-06-25 3:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-25 3:17 [PATCH 1/4] optimize verify-pack a bit Nicolas Pitre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).