From: Junio C Hamano Date: Thu, 14 Jan 2021 06:42:45 GMT Subject: Re: [PATCH v2 18/20] pack-revindex: remove unused 'find_revindex_position()' Message-ID: In-Reply-To: <3b5c92be684b95f04cbe224c791d87657be9ff79.1610576604.git.me@ttaylorr.com> Taylor Blau writes: > -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 OK, we can safely depend on "unsigned int" at least as wide as "uint32_t"; unlike the original that used "int", we won't risk losing the upper half of 4G range. Nice.