refactor: some small stuff
This commit is contained in:
parent
f9a5fc14e5
commit
2d89c5e80f
3 changed files with 10 additions and 8 deletions
|
|
@ -236,17 +236,19 @@ bool trie_add_no_lock(Trie *trie, const char *string, Entry *entry) {
|
|||
offset = 0;
|
||||
child_node_ptr = tnode_search(*node_ptr, string[i], true);
|
||||
|
||||
i++;
|
||||
|
||||
// We've reached a NULL child, so we add the remaining part of the string
|
||||
// here
|
||||
if (*child_node_ptr == NULL) {
|
||||
child_node = tnode_init();
|
||||
|
||||
while (offset < TRIE_MAX_SKIP_SIZE &&
|
||||
string[i + 1 + offset] != DELIMITER) {
|
||||
string[i + offset] != DELIMITER) {
|
||||
offset++;
|
||||
}
|
||||
|
||||
memcpy(child_node->string, string + i + 1, offset);
|
||||
memcpy(child_node->string, string + i, offset);
|
||||
|
||||
child_node->string_len = offset;
|
||||
*child_node_ptr = child_node;
|
||||
|
|
@ -255,9 +257,9 @@ bool trie_add_no_lock(Trie *trie, const char *string, Entry *entry) {
|
|||
// allowed skip length, we continue through the loop. The next iteration
|
||||
// will enter this if statement again, and perform the same loop, until
|
||||
// the string is fully added to the trie.
|
||||
if (string[i + 1 + offset] != DELIMITER) {
|
||||
if (string[i + offset] != DELIMITER) {
|
||||
node_ptr = child_node_ptr;
|
||||
i += offset + 1;
|
||||
i += offset;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
@ -269,8 +271,6 @@ bool trie_add_no_lock(Trie *trie, const char *string, Entry *entry) {
|
|||
return true;
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
while (offset < (*child_node_ptr)->string_len) {
|
||||
// String no longer aligns with edge, so we have to split
|
||||
if (string[i + offset] != (*child_node_ptr)->string[offset]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue