Skip to content

Commit 0c6804a

Browse files
pcloudsgitster
authored andcommitted
pack-objects: use bitfield for object_entry::dfs_state
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fd9b1ba commit 0c6804a

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

builtin/pack-objects.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,6 +3049,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
30493049
OPT_END(),
30503050
};
30513051

3052+
if (DFS_NUM_STATES > (1 << OE_DFS_STATE_BITS))
3053+
BUG("too many dfs states, increase OE_DFS_STATE_BITS");
3054+
30523055
check_replace_refs = 0;
30533056

30543057
reset_pack_idx_option(&pack_idx_opts);

pack-objects.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
#ifndef PACK_OBJECTS_H
22
#define PACK_OBJECTS_H
33

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+
419
/*
520
* basic object info
621
* -----------------
@@ -73,19 +88,10 @@ struct object_entry {
7388
unsigned no_try_delta:1;
7489
unsigned tagged:1; /* near the very tip of refs */
7590
unsigned filled:1; /* assigned write-order */
91+
unsigned dfs_state:OE_DFS_STATE_BITS;
7692

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;
8893
int depth;
94+
8995
};
9096

9197
struct packing_data {

0 commit comments

Comments
 (0)