diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2019-03-05 22:58:11 -0800 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2019-03-05 22:58:11 -0800 |
commit | eac589caf97daece0523e5e768765d584851f4ce (patch) | |
tree | 0ac1597e9d354be78a27f1b1de031d6e53f38abf | |
parent | 2b5d4d7510b97b118754de000ad52d58fdfad7bf (diff) | |
download | bfs-eac589caf97daece0523e5e768765d584851f4ce.tar.xz |
trie: Minor optimization
-rw-r--r-- | trie.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -204,14 +204,13 @@ static struct trie_leaf *trie_representative(const struct trie *trie, const void struct trie_node *node = trie_decode_node(ptr); offset += node->offset; - unsigned char nibble = 0; - if ((offset >> 1) < length) { - nibble = trie_key_nibble(key, offset); - } - unsigned int bit = 1U << nibble; unsigned int index = 0; - if (node->bitmap & bit) { - index = trie_popcount(node->bitmap & (bit - 1)); + if ((offset >> 1) < length) { + unsigned char nibble = trie_key_nibble(key, offset); + unsigned int bit = 1U << nibble; + if (node->bitmap & bit) { + index = trie_popcount(node->bitmap & (bit - 1)); + } } ptr = node->children[index]; } |