From 108f530385e969feab343b2b8acadeb7bb670009 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Thu, 16 Aug 2018 08:13:12 +0200 Subject: pack-objects: move tree_depth into 'struct packing_data' This reduces the size of 'struct object_entry' and therefore makes packing objects more efficient. This also renames cmp_tree_depth() into tree_depth_compare(), as it is more modern to have the name of the compare functions end with "compare". Helped-by: Jeff King Helped-by: Duy Nguyen Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- pack-objects.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'pack-objects.h') diff --git a/pack-objects.h b/pack-objects.h index 8eecd67991..3cb5527eeb 100644 --- a/pack-objects.h +++ b/pack-objects.h @@ -101,7 +101,6 @@ struct object_entry { unsigned no_try_delta:1; unsigned in_pack_type:TYPE_BITS; /* could be delta */ - unsigned int tree_depth; /* should be repositioned for packing? */ unsigned char layer; unsigned preferred_base:1; /* @@ -145,6 +144,9 @@ struct packing_data { struct packed_git **in_pack; uintmax_t oe_size_limit; + + /* delta islands */ + unsigned int *tree_depth; }; void prepare_packing_data(struct packing_data *pdata); @@ -350,4 +352,21 @@ static inline void oe_set_delta_size(struct packing_data *pack, "where delta size is the same as entry size"); } +static inline unsigned int oe_tree_depth(struct packing_data *pack, + struct object_entry *e) +{ + if (!pack->tree_depth) + return 0; + return pack->tree_depth[e - pack->objects]; +} + +static inline void oe_set_tree_depth(struct packing_data *pack, + struct object_entry *e, + unsigned int tree_depth) +{ + if (!pack->tree_depth) + ALLOC_ARRAY(pack->tree_depth, pack->nr_objects); + pack->tree_depth[e - pack->objects] = tree_depth; +} + #endif -- cgit v1.2.3