summaryrefslogtreecommitdiff
path: root/lib/command.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-10-06 01:16:47 -0300
committerRenato Westphal <renato@opensourcerouting.org>2019-10-11 21:18:36 -0300
commit5e6a9350c16f54113eeedb497c98fe45b8ce6222 (patch)
treea4931a1274531b4b1d975ff9ca23bc70670b9676 /lib/command.c
parentc7c9103b01899d316372cc0272c37df9a7e59426 (diff)
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 <renato@opensourcerouting.org>
Diffstat (limited to 'lib/command.c')
-rw-r--r--lib/command.c2
1 files changed, 2 insertions, 0 deletions
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");