mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-23 10:11:53 +00:00
Filter/Trie: jump over branches that are never true in first iteration
This commit is contained in:
parent
531e0359d7
commit
763c124ef8
@ -163,6 +163,8 @@ trie_add_prefix(struct f_trie *t, const net_addr *net, uint l, uint h)
|
|||||||
struct f_trie_node *o = NULL;
|
struct f_trie_node *o = NULL;
|
||||||
struct f_trie_node *n = t->root;
|
struct f_trie_node *n = t->root;
|
||||||
|
|
||||||
|
switch (0)
|
||||||
|
{
|
||||||
while (n)
|
while (n)
|
||||||
{
|
{
|
||||||
ip_addr cmask = ipa_and(n->mask, pmask);
|
ip_addr cmask = ipa_and(n->mask, pmask);
|
||||||
@ -197,6 +199,9 @@ trie_add_prefix(struct f_trie *t, const net_addr *net, uint l, uint h)
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The two conditions until here are always false if n == t->root */
|
||||||
|
case 0:
|
||||||
|
|
||||||
if (plen == n->plen)
|
if (plen == n->plen)
|
||||||
{
|
{
|
||||||
/* We already found added node in trie. Just update accept mask */
|
/* We already found added node in trie. Just update accept mask */
|
||||||
@ -211,6 +216,7 @@ trie_add_prefix(struct f_trie *t, const net_addr *net, uint l, uint h)
|
|||||||
o = n;
|
o = n;
|
||||||
n = n->c[ipa_getbit(paddr, n->plen) ? 1 : 0];
|
n = n->c[ipa_getbit(paddr, n->plen) ? 1 : 0];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* We add new tail node 'a' after node 'o' */
|
/* We add new tail node 'a' after node 'o' */
|
||||||
struct f_trie_node *a = new_node(t, plen, paddr, pmask, amask);
|
struct f_trie_node *a = new_node(t, plen, paddr, pmask, amask);
|
||||||
|
Loading…
Reference in New Issue
Block a user