This reverts commit 0aca34e8269514ebb67676e0470a314615494ae8. --- builtin/pack-objects.c | 26 ++++++++++---------------- pack-objects.h | 23 +---------------------- 2 files changed, 11 insertions(+), 38 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 71056d8294..4775b4b4e5 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -35,12 +35,10 @@ #define IN_PACK(obj) oe_in_pack(&to_pack, obj) #define SIZE(obj) oe_size(&to_pack, obj) #define SET_SIZE(obj,size) oe_set_size(&to_pack, obj, size) -#define DELTA_SIZE(obj) oe_delta_size(&to_pack, obj) #define DELTA(obj) oe_delta(&to_pack, obj) #define DELTA_CHILD(obj) oe_delta_child(&to_pack, obj) #define DELTA_SIBLING(obj) oe_delta_sibling(&to_pack, obj) #define SET_DELTA(obj, val) oe_set_delta(&to_pack, obj, val) -#define SET_DELTA_SIZE(obj, val) oe_set_delta_size(&to_pack, obj, val) #define SET_DELTA_CHILD(obj, val) oe_set_delta_child(&to_pack, obj, val) #define SET_DELTA_SIBLING(obj, val) oe_set_delta_sibling(&to_pack, obj, val) @@ -148,7 +146,7 @@ static void *get_delta(struct object_entry *entry) oid_to_hex(&DELTA(entry)->idx.oid)); delta_buf = diff_delta(base_buf, base_size, buf, size, &delta_size, 0); - if (!delta_buf || delta_size != DELTA_SIZE(entry)) + if (!delta_buf || delta_size != entry->delta_size) die("delta size changed"); free(buf); free(base_buf); @@ -299,14 +297,14 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent FREE_AND_NULL(entry->delta_data); entry->z_delta_size = 0; } else if (entry->delta_data) { - size = DELTA_SIZE(entry); + size = entry->delta_size; buf = entry->delta_data; entry->delta_data = NULL; type = (allow_ofs_delta && DELTA(entry)->idx.offset) ? OBJ_OFS_DELTA : OBJ_REF_DELTA; } else { buf = get_delta(entry); - size = DELTA_SIZE(entry); + size = entry->delta_size; type = (allow_ofs_delta && DELTA(entry)->idx.offset) ? OBJ_OFS_DELTA : OBJ_REF_DELTA; } @@ -1518,7 +1516,7 @@ static void check_object(struct object_entry *entry) oe_set_type(entry, entry->in_pack_type); SET_SIZE(entry, in_pack_size); /* delta size */ SET_DELTA(entry, base_entry); - SET_DELTA_SIZE(entry, in_pack_size); + entry->delta_size = in_pack_size; entry->delta_sibling_idx = base_entry->delta_child_idx; SET_DELTA_CHILD(base_entry, entry); unuse_pack(&w_curs); @@ -1954,7 +1952,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, max_size = trg_size/2 - the_hash_algo->rawsz; ref_depth = 1; } else { - max_size = DELTA_SIZE(trg_entry); + max_size = trg_entry->delta_size; ref_depth = trg->depth; } max_size = (uint64_t)max_size * (max_depth - src->depth) / @@ -2023,14 +2021,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, delta_buf = create_delta(src->index, trg->data, trg_size, &delta_size, max_size); if (!delta_buf) return 0; - if (delta_size >= (1U << OE_DELTA_SIZE_BITS)) { - free(delta_buf); - return 0; - } if (DELTA(trg_entry)) { /* Prefer only shallower same-sized deltas. */ - if (delta_size == DELTA_SIZE(trg_entry) && + if (delta_size == trg_entry->delta_size && src->depth + 1 >= trg->depth) { free(delta_buf); return 0; @@ -2045,7 +2039,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, free(trg_entry->delta_data); cache_lock(); if (trg_entry->delta_data) { - delta_cache_size -= DELTA_SIZE(trg_entry); + delta_cache_size -= trg_entry->delta_size; trg_entry->delta_data = NULL; } if (delta_cacheable(src_size, trg_size, delta_size)) { @@ -2058,7 +2052,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, } SET_DELTA(trg_entry, src_entry); - SET_DELTA_SIZE(trg_entry, delta_size); + trg_entry->delta_size = delta_size; trg->depth = src->depth + 1; return 1; @@ -2181,11 +2175,11 @@ static void find_deltas(struct object_entry **list, unsigned *list_size, if (entry->delta_data && !pack_to_stdout) { unsigned long size; - size = do_compress(&entry->delta_data, DELTA_SIZE(entry)); + size = do_compress(&entry->delta_data, entry->delta_size); if (size < (1U << OE_Z_DELTA_BITS)) { entry->z_delta_size = size; cache_lock(); - delta_cache_size -= DELTA_SIZE(entry); + delta_cache_size -= entry->delta_size; delta_cache_size += entry->z_delta_size; cache_unlock(); } else { diff --git a/pack-objects.h b/pack-objects.h index edf74dabdd..0e08f10437 100644 --- a/pack-objects.h +++ b/pack-objects.h @@ -14,7 +14,6 @@ * above this limit. Don't lower it too much. */ #define OE_SIZE_BITS 31 -#define OE_DELTA_SIZE_BITS 20 /* * State flags for depth-first search used for analyzing delta cycles. @@ -92,8 +91,7 @@ struct object_entry { uint32_t delta_sibling_idx; /* other deltified objects who * uses the same base as me */ - unsigned delta_size_:OE_DELTA_SIZE_BITS; /* delta data size (uncompressed) */ - unsigned delta_size_valid:1; + unsigned long delta_size; /* delta data size (uncompressed) */ unsigned in_pack_idx:OE_IN_PACK_BITS; /* already in pack */ unsigned z_delta_size:OE_Z_DELTA_BITS; unsigned type_valid:1; @@ -327,23 +325,4 @@ static inline void oe_set_size(struct packing_data *pack, } } -static inline unsigned long oe_delta_size(struct packing_data *pack, - const struct object_entry *e) -{ - if (e->delta_size_valid) - return e->delta_size_; - return oe_size(pack, e); -} - -static inline void oe_set_delta_size(struct packing_data *pack, - struct object_entry *e, - unsigned long size) -{ - e->delta_size_ = size; - e->delta_size_valid = e->delta_size_ == size; - if (!e->delta_size_valid && size != oe_size(pack, e)) - BUG("this can only happen in check_object() " - "where delta size is the same as entry size"); -} - #endif -- 2.18.0.1.gd83e732e4e