mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 08:32:45 +00:00
lib: nexthop_group_equal() assume ordered
Speed up nexthop_group_equal() by making it assume the groups it has been passed are ordered. This should always be the case. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
This commit is contained in:
parent
e4ac313b12
commit
12ec584da8
@ -132,10 +132,12 @@ struct nexthop *nexthop_exists(const struct nexthop_group *nhg,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This assumes ordered */
|
||||||
bool nexthop_group_equal(const struct nexthop_group *nhg1,
|
bool nexthop_group_equal(const struct nexthop_group *nhg1,
|
||||||
const struct nexthop_group *nhg2)
|
const struct nexthop_group *nhg2)
|
||||||
{
|
{
|
||||||
struct nexthop *nh = NULL;
|
struct nexthop *nh1 = NULL;
|
||||||
|
struct nexthop *nh2 = NULL;
|
||||||
|
|
||||||
if (nhg1 && !nhg2)
|
if (nhg1 && !nhg2)
|
||||||
return false;
|
return false;
|
||||||
@ -147,8 +149,9 @@ bool nexthop_group_equal(const struct nexthop_group *nhg1,
|
|||||||
!= nexthop_group_nexthop_num_no_recurse(nhg2))
|
!= nexthop_group_nexthop_num_no_recurse(nhg2))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (nh = nhg1->nexthop; nh; nh = nh->next) {
|
for (nh1 = nhg1->nexthop, nh2 = nhg2->nexthop; nh1 && nh2;
|
||||||
if (!nexthop_exists(nhg2, nh))
|
nh1 = nh1->next, nh2 = nh2->next) {
|
||||||
|
if (!nexthop_same(nh1, nh2))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user