From 5e6a9350c16f54113eeedb497c98fe45b8ce6222 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Sun, 6 Oct 2019 01:16:47 -0300 Subject: lib: avoid expensive operations when editing a candidate config nb_candidate_edit() was calling both the lyd_schema_sort() and lyd_validate() functions whenever a new node was added to the candidate configuration. This was done to ensure the candidate is always ready to be displayed correctly (libyang only creates default child nodes during the validation process, and data nodes aren't guaranteed to be ordered by default). The problem is that the two aforementioned functions are too expensive to be called in the northbound hot path. Instead, it makes more sense to call them only before displaying the configuration (in which case a recursive sort needs to be done). Introduce the nb_cli_show_config_prepare() to achieve that purpose. Signed-off-by: Renato Westphal --- lib/command.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/command.c') diff --git a/lib/command.c b/lib/command.c index 04f2bd95a0..32e877280d 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1709,6 +1709,8 @@ static int vty_write_config(struct vty *vty) if (host.noconfig) return CMD_SUCCESS; + nb_cli_show_config_prepare(running_config, false); + if (vty->type == VTY_TERM) { vty_out(vty, "\nCurrent configuration:\n"); vty_out(vty, "!\n"); -- cgit v1.2.3