summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2019-03-05 22:58:11 -0800
committerTavian Barnes <tavianator@tavianator.com>2019-03-05 22:58:11 -0800
commiteac589caf97daece0523e5e768765d584851f4ce (patch)
tree0ac1597e9d354be78a27f1b1de031d6e53f38abf
parent2b5d4d7510b97b118754de000ad52d58fdfad7bf (diff)
downloadbfs-eac589caf97daece0523e5e768765d584851f4ce.tar.xz
trie: Minor optimization
-rw-r--r--trie.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/trie.c b/trie.c
index 425cfe1..c38ad2c 100644
--- a/trie.c
+++ b/trie.c
@@ -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];
}