mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Several simplifications of the fib iterators.
This commit is contained in:
parent
0bcba21e89
commit
8abbde02d4
13
nest/route.h
13
nest/route.h
@ -86,12 +86,13 @@ void fit_put(struct fib_iterator *, struct fib_node *);
|
|||||||
unsigned int count = (fib)->hash_size; \
|
unsigned int count = (fib)->hash_size; \
|
||||||
unsigned int hpos = (it)->hash; \
|
unsigned int hpos = (it)->hash; \
|
||||||
for(;;) { \
|
for(;;) { \
|
||||||
fis_again: if (!z) { \
|
if (!z) \
|
||||||
if (++hpos >= count) \
|
{ \
|
||||||
break; \
|
if (++hpos >= count) \
|
||||||
z = (fib)->hash_table[hpos]; \
|
break; \
|
||||||
goto fis_again; \
|
z = (fib)->hash_table[hpos]; \
|
||||||
}
|
continue; \
|
||||||
|
}
|
||||||
|
|
||||||
#define FIB_ITERATE_END(z) z = z->next; } } while(0)
|
#define FIB_ITERATE_END(z) z = z->next; } } while(0)
|
||||||
|
|
||||||
|
@ -163,20 +163,20 @@ fib_merge_readers(struct fib_iterator *i, struct fib_node *to)
|
|||||||
/* Fast path */
|
/* Fast path */
|
||||||
to->readers = i;
|
to->readers = i;
|
||||||
i->prev = (struct fib_iterator *) to;
|
i->prev = (struct fib_iterator *) to;
|
||||||
fixup:
|
|
||||||
while (i && i->node)
|
|
||||||
{
|
|
||||||
i->node = NULL;
|
|
||||||
i = i->next;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
/* Really merging */
|
else
|
||||||
while (j->next)
|
{
|
||||||
j = j->next;
|
/* Really merging */
|
||||||
j->next = i;
|
while (j->next)
|
||||||
i->prev = j;
|
j = j->next;
|
||||||
goto fixup;
|
j->next = i;
|
||||||
|
i->prev = j;
|
||||||
|
}
|
||||||
|
while (i && i->node)
|
||||||
|
{
|
||||||
|
i->node = NULL;
|
||||||
|
i = i->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else /* No more nodes */
|
else /* No more nodes */
|
||||||
while (i)
|
while (i)
|
||||||
@ -260,7 +260,7 @@ fit_get(struct fib *f, struct fib_iterator *i)
|
|||||||
if (!i->prev)
|
if (!i->prev)
|
||||||
{
|
{
|
||||||
/* We are at the end */
|
/* We are at the end */
|
||||||
i->hash = f->hash_size;
|
i->hash = ~0 - 1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!(n = i->node))
|
if (!(n = i->node))
|
||||||
|
Loading…
Reference in New Issue
Block a user