]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter/Trie: jump over branches that are never true in first iteration
authorMaria Matejka <mq@ucw.cz>
Wed, 14 Aug 2019 09:50:11 +0000 (11:50 +0200)
committerMaria Matejka <mq@ucw.cz>
Sat, 17 Aug 2019 11:47:22 +0000 (13:47 +0200)
filter/trie.c

index adcfcdf3f031fea798db44985429d9f8be0bdead..3fe388fbfafa84d0d9cf969806e611007858764b 100644 (file)
@@ -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 *n = t->root;
 
+  switch (0)
+  {
   while (n)
     {
       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;
        }
 
+      /* The two conditions until here are always false if n == t->root */
+      case 0:
+
       if (plen == n->plen)
        {
          /* 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;
       n = n->c[ipa_getbit(paddr, n->plen) ? 1 : 0];
     }
+  }
 
   /* We add new tail node 'a' after node 'o' */
   struct f_trie_node *a = new_node(t, plen, paddr, pmask, amask);