Re: [PATCH 01/14] oidtree: modernize the code a bit
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 19, 2026, 16:08 UTC
- Message-ID
- <xmqqeclfn6nn.fsf@gitster.g>
- In-Reply-To
- <20260319-b4-pks-odb-source-abbrev-v1-1-5ddebad292b0@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 20 quoted lines
> +void oidtree_each(struct oidtree *ot, const struct object_id *prefix,
> + size_t prefix_hex_len, oidtree_each_cb cb, void *cb_data)
> {
> - size_t klen = oidhexsz / 2;
> - struct oidtree_iter_data x = { 0 };
> - assert(oidhexsz <= GIT_MAX_HEXSZ);
> -
> - x.fn = fn;
> - x.arg = arg;
> - x.algo = oid->algo;
> - if (oidhexsz & 1) {
> - x.last_byte = oid->hash[klen];
> - x.last_nibble_at = &klen;
> + struct oidtree_each_data data = {
> + .cb = cb,
> + .cb_data = cb_data,
> + .algo = prefix->algo,
> + };
> + size_t klen = prefix_hex_len / 2;
> + assert(prefix_hex_len <= GIT_MAX_HEXSZ);I know the original also used GIT_MAX_HEXSZ to clamp the length for sanity, but because we know what algorithm is in use, I wonder if we want to use the limit more specific to it.