feat: remove edge case checking for empty key
parent
88ea0db2ee
commit
1e5442379f
21
src/trie.c
21
src/trie.c
|
@ -134,15 +134,6 @@ typedef struct searchresult {
|
|||
SearchResult trie_search_node(Trie *trie, const char *key) {
|
||||
SearchResult out = {NULL, NULL};
|
||||
|
||||
// Edge case for empty string
|
||||
if (key[0] == DELIMITER) {
|
||||
if (trie->root->represents) {
|
||||
out.child = trie->root;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
size_t offset;
|
||||
TrieNode **node_ptr = &(trie->root);
|
||||
|
@ -229,18 +220,6 @@ Entry *trie_search(Trie *trie, const char *key) {
|
|||
*/
|
||||
bool trie_add_no_lock(Trie *trie, const char *string,
|
||||
Entry *entry) {
|
||||
// Edge case for empty string
|
||||
if (string[0] == DELIMITER) {
|
||||
if (trie->root->represents) {
|
||||
return false;
|
||||
}
|
||||
|
||||
trie->root->represents = true;
|
||||
trie->size++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
uint8_t offset;
|
||||
TrieNode **node_ptr = &(trie->root);
|
||||
|
|
Loading…
Reference in New Issue