@@ -37,19 +37,15 @@ namespace internal {
3737#endif
3838
3939typedef uint8_t art_typecode_t ;
40-
41- // All node types should count as unoccupied if zeroed with memset.
42-
4340typedef void art_node_t ;
4441
4542typedef struct art_leaf_s {
46- bool occupied ;
4743 union {
4844 struct {
4945 art_key_chunk_t key [ART_KEY_BYTES ];
5046 art_val_t val ;
5147 };
52- size_t next_free ; // Used if !occupied.
48+ size_t next_free ;
5349 };
5450} art_leaf_t ;
5551
@@ -65,59 +61,59 @@ typedef struct art_inner_node_s {
6561
6662// Node4: key[i] corresponds with children[i]. Keys are sorted.
6763typedef struct art_node4_s {
68- art_inner_node_t base ;
69- uint8_t count ;
7064 union {
7165 struct {
66+ art_inner_node_t base ;
67+ uint8_t count ;
7268 uint8_t keys [4 ];
7369 art_ref_t children [4 ];
7470 };
75- size_t next_free ; // Used if count == 0.
71+ size_t next_free ;
7672 };
7773} art_node4_t ;
7874
7975// Node16: key[i] corresponds with children[i]. Keys are sorted.
8076typedef struct art_node16_s {
81- art_inner_node_t base ;
82- uint8_t count ;
8377 union {
8478 struct {
79+ art_inner_node_t base ;
80+ uint8_t count ;
8581 uint8_t keys [16 ];
8682 art_ref_t children [16 ];
8783 };
88- size_t next_free ; // Used if count == 0.
84+ size_t next_free ;
8985 };
9086} art_node16_t ;
9187
9288// Node48: key[i] corresponds with children[key[i]] if key[i] !=
9389// CROARING_ART_NODE48_EMPTY_VAL. Keys are naturally sorted due to direct
9490// indexing.
9591typedef struct art_node48_s {
96- art_inner_node_t base ;
97- uint8_t count ;
9892 union {
9993 struct {
94+ art_inner_node_t base ;
95+ uint8_t count ;
10096 // Bitset where the ith bit is set if children[i] is available
10197 // Because there are at most 48 children, only the bottom 48 bits
10298 // are used.
10399 uint64_t available_children ;
104100 uint8_t keys [256 ];
105101 art_ref_t children [48 ];
106102 };
107- size_t next_free ; // Used if count == 0.
103+ size_t next_free ;
108104 };
109105} art_node48_t ;
110106
111107// Node256: children[i] is directly indexed by key chunk. A child is present if
112108// children[i] != NULL.
113109typedef struct art_node256_s {
114- art_inner_node_t base ;
115- uint16_t count ;
116110 union {
117111 struct {
112+ art_inner_node_t base ;
113+ uint16_t count ;
118114 art_ref_t children [256 ];
119115 };
120- size_t next_free ; // Used if count == 0.
116+ size_t next_free ;
121117 };
122118} art_node256_t ;
123119
@@ -235,14 +231,12 @@ static art_ref_t art_leaf_create(art_t *art, const art_key_chunk_t key[],
235231 art_val_t val ) {
236232 uint64_t index = art_allocate_index (art , CROARING_ART_LEAF_TYPE );
237233 art_leaf_t * leaf = art -> leaves + index ;
238- leaf -> occupied = true;
239234 memcpy (leaf -> key , key , ART_KEY_BYTES );
240235 leaf -> val = val ;
241236 return art_to_ref (index , CROARING_ART_LEAF_TYPE );
242237}
243238
244239static inline void art_leaf_clear (art_leaf_t * leaf , art_ref_t next_free ) {
245- leaf -> occupied = false;
246240 leaf -> next_free = next_free ;
247241}
248242
0 commit comments