diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-11-02 11:18:37 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-11-04 12:26:38 -0500 |
commit | 7841bfe55d4b5aa85e6d6f661f30f9eecbc84374 (patch) | |
tree | f2fd3375c3760e0aaffb1d839227b999c686fb9b /src | |
parent | f9731a2ee6917ce5c389444e52cfa99bea873edb (diff) | |
download | bfs-7841bfe55d4b5aa85e6d6f661f30f9eecbc84374.tar.xz |
trie: Get rid of the linked list of leavesslab-bitmaps
Diffstat (limited to 'src')
-rw-r--r-- | src/trie.c | 8 | ||||
-rw-r--r-- | src/trie.h | 6 |
2 files changed, 1 insertions, 13 deletions
@@ -87,7 +87,6 @@ #include "bfs.h" #include "bit.h" #include "diag.h" -#include "list.h" #include <stdint.h> #include <string.h> @@ -165,7 +164,6 @@ static uintptr_t trie_encode_leaf(const struct trie_leaf *leaf) { void trie_init(struct trie *trie) { trie->root = 0; - LIST_INIT(trie); VARENA_INIT(&trie->nodes, struct trie_node, children); VARENA_INIT(&trie->leaves, struct trie_leaf, key); } @@ -339,9 +337,6 @@ static struct trie_leaf *trie_leaf_alloc(struct trie *trie, const void *key, siz return NULL; } - LIST_ITEM_INIT(leaf); - LIST_APPEND(trie, leaf); - leaf->value = NULL; leaf->length = length; memcpy(leaf->key, key, length); @@ -351,7 +346,6 @@ static struct trie_leaf *trie_leaf_alloc(struct trie *trie, const void *key, siz /** Free a leaf. */ static void trie_leaf_free(struct trie *trie, struct trie_leaf *leaf) { - LIST_REMOVE(trie, leaf); varena_free(&trie->leaves, leaf); } @@ -736,8 +730,6 @@ void trie_remove(struct trie *trie, struct trie_leaf *leaf) { void trie_clear(struct trie *trie) { trie->root = 0; - LIST_INIT(trie); - varena_clear(&trie->leaves); varena_clear(&trie->nodes); } @@ -14,8 +14,6 @@ * A leaf of a trie. */ struct trie_leaf { - /** Linked list of leaves, in insertion order. */ - struct trie_leaf *prev, *next; /** An arbitrary value associated with this leaf. */ void *value; /** The length of the key in bytes. */ @@ -30,8 +28,6 @@ struct trie_leaf { struct trie { /** Pointer to the root node/leaf. */ uintptr_t root; - /** Linked list of leaves. */ - struct trie_leaf *head, *tail; /** Node allocator. */ struct varena nodes; /** Leaf allocator. */ @@ -143,6 +139,6 @@ void trie_destroy(struct trie *trie); * Iterate over the leaves of a trie. */ #define for_trie(leaf, trie) \ - for_list (struct trie_leaf, leaf, trie) + for_varena (struct trie_leaf, leaf, &(trie)->leaves) #endif // BFS_TRIE_H |