diff options
-rw-r--r-- | pack-revindex.c | 31 | ||||
-rw-r--r-- | pack-revindex.h | 1 |
2 files changed, 12 insertions, 20 deletions
diff --git a/pack-revindex.c b/pack-revindex.c index 16baafb281..282fe92640 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -169,16 +169,23 @@ int load_pack_revindex(struct packed_git *p) return 0; } -int find_revindex_position(struct packed_git *p, off_t ofs) +int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos) { - int lo = 0; - int hi = p->num_objects + 1; - const struct revindex_entry *revindex = p->revindex; + unsigned lo, hi; + const struct revindex_entry *revindex; + + if (load_pack_revindex(p) < 0) + return -1; + + lo = 0; + hi = p->num_objects + 1; + revindex = p->revindex; do { const unsigned mi = lo + (hi - lo) / 2; if (revindex[mi].offset == ofs) { - return mi; + *pos = mi; + return 0; } else if (ofs < revindex[mi].offset) hi = mi; else @@ -189,20 +196,6 @@ int find_revindex_position(struct packed_git *p, off_t ofs) return -1; } -int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos) -{ - int ret; - - if (load_pack_revindex(p) < 0) - return -1; - - ret = find_revindex_position(p, ofs); - if (ret < 0) - return ret; - *pos = ret; - return 0; -} - uint32_t pack_pos_to_index(struct packed_git *p, uint32_t pos) { if (!p->revindex) diff --git a/pack-revindex.h b/pack-revindex.h index f7094ba9a5..746776be7f 100644 --- a/pack-revindex.h +++ b/pack-revindex.h @@ -28,7 +28,6 @@ struct revindex_entry { * given pack, returning zero on success and a negative value otherwise. */ int load_pack_revindex(struct packed_git *p); -int find_revindex_position(struct packed_git *p, off_t ofs); /* * offset_to_pack_pos converts an object offset to a pack position. This |