lib: optimize vrf_id_to_name(VRF_DEFAULT) case

vrf_id_to_name() looks up in a RB_TREE to find the VRF entry, then
reads the name.

Avoid it for VRF_DEFAULT, which always exists and for which the
translation is straightforward.

Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
This commit is contained in:
Christophe Gouault 2020-08-26 16:26:49 +02:00
parent 8277d4b796
commit 7c1119cb7a

View File

@ -331,6 +331,9 @@ const char *vrf_id_to_name(vrf_id_t vrf_id)
{
struct vrf *vrf;
if (vrf_id == VRF_DEFAULT)
return VRF_DEFAULT_NAME;
vrf = vrf_lookup_by_id(vrf_id);
return VRF_LOGNAME(vrf);
}