pack-objects: use bitfield for object_entry::dfs_state

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Apr 14, 2018 at 17:35 UTC 0c6804ab4ee5cfa47fe28e0a2d20415c5c1f8884
2 files changed +20 -11
builtin/pack-objects.c
+3
@@ -3049,6 +3049,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3049 OPT_END(),
3050 };
3051
3052 + if (DFS_NUM_STATES > (1 << OE_DFS_STATE_BITS))
3053 + BUG("too many dfs states, increase OE_DFS_STATE_BITS");
3054 +
3055 check_replace_refs = 0;
3056
3057 reset_pack_idx_option(&pack_idx_opts);
pack-objects.h
+17 -11
@@ -1,6 +1,21 @@
1 #ifndef PACK_OBJECTS_H
2 #define PACK_OBJECTS_H
3
4 +#define OE_DFS_STATE_BITS 2
5 +
6 +/*
7 + * State flags for depth-first search used for analyzing delta cycles.
8 + *
9 + * The depth is measured in delta-links to the base (so if A is a delta
10 + * against B, then A has a depth of 1, and B a depth of 0).
11 + */
12 +enum dfs_state {
13 + DFS_NONE = 0,
14 + DFS_ACTIVE,
15 + DFS_DONE,
16 + DFS_NUM_STATES
17 +};
18 +
19 /*
20 * basic object info
21 * -----------------
@@ -73,19 +88,10 @@ struct object_entry {
88 unsigned no_try_delta:1;
89 unsigned tagged:1; /* near the very tip of refs */
90 unsigned filled:1; /* assigned write-order */
91 + unsigned dfs_state:OE_DFS_STATE_BITS;
92
77 - /*
78 - * State flags for depth-first search used for analyzing delta cycles.
79 - *
80 - * The depth is measured in delta-links to the base (so if A is a delta
81 - * against B, then A has a depth of 1, and B a depth of 0).
82 - */
83 - enum {
84 - DFS_NONE = 0,
85 - DFS_ACTIVE,
86 - DFS_DONE
87 - } dfs_state;
93 int depth;
94 +
95 };
96
97 struct packing_data {