Re: [PATCH v2 18/20] pack-revindex: remove unused 'find_revindex_position()'
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 14, 2021, 06:42 UTC
- Message-ID
- <xmqqft34yq6y.fsf@gitster.c.googlers.com>
- In-Reply-To
- <3b5c92be684b95f04cbe224c791d87657be9ff79.1610576604.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
Show 24 quoted lines
> -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;
> elseOK, 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.