On Sun, Jul 5, 2015 at 5:30 AM, Junio C Hamano <gits...@pobox.com> wrote:
> When c6458e60 (index-pack: kill union delta_base to save memory,
> 2015-04-18) attempted to reduce the memory footprint of index-pack,
> one of the key thing it did was to keep track of ref-deltas and
> ofs-deltas separately.
>
> In fix_unresolved_deltas(), however it forgot that it now wants to
> look only at ref deltas in one place.  The code allocated an array
> for nr_unresolved, which is sum of number of ref- and ofs-deltas
> minus nr_resolved, which may be larger or smaller than the number
> ref-deltas.  Depending on nr_resolved, this was either under or over
> allocating.

It's either that or we could put back "if (real_type != OBJ_REF_DELTA)
continue;" in the sorted_by_pos population loop. Resolved deltas can't
have real_type == OBJ_REF_DELTA, so if we allocate nr_unresolved, it's
guaranteed over-allocation, never under-allocation. But I guess your
approach would make the code easier to read.

I keep tripping over this "real_type vs type" in this code. What do
you think about renaming "type" field to "in_pack_type" and
"real_type" to "canon_type" (or "final_type")? "Real" does not really
say anything in this context..
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to