From 7c1119cb7a1c66028d5487ff66682383244f987d Mon Sep 17 00:00:00 2001 From: Christophe Gouault Date: Wed, 26 Aug 2020 16:26:49 +0200 Subject: [PATCH] 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 --- lib/vrf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/vrf.c b/lib/vrf.c index cc7445558c..a7e9b256f2 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -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); } -- 2.39.5