From a97a66cb92e7b23a9a4c3f191064a4410be6d803 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Mon, 29 May 2023 10:47:00 +0200 Subject: [PATCH] Performance: A change in the `merge` code made "co-located" config and non-config get retrieval go considerable faster. --- CHANGELOG.md | 2 +- apps/backend/backend_commit.c | 3 ++- lib/src/clixon_xml.c | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 412356e4..512fd027 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,9 +57,9 @@ Developers may need to change their code * `yang2cli_yspec` removed last argument `printgen`. * Removed obsolete: `cli_auto_show()` - ### Minor features +* Performance: A change in the `merge` code made "co-located" config and non-config get retrieval go considerable faster. * CLI: Added `show statistics` example code for backend and CLI memory stats * [Support yang type union with are same subtypes with SNMP](https://github.com/clicon/clixon/pull/427) * Removed obsolete compile options introduced in 6.1: diff --git a/apps/backend/backend_commit.c b/apps/backend/backend_commit.c index d017b3d6..f1579b10 100644 --- a/apps/backend/backend_commit.c +++ b/apps/backend/backend_commit.c @@ -520,7 +520,8 @@ validate_common(clicon_handle h, &td->td_tcvec, /* changed: wanted values */ &td->td_clen) < 0) goto done; - transaction_dbg(h, CLIXON_DBG_DETAIL, td, __FUNCTION__); + if (dbglevel & CLIXON_DBG_DETAIL) + transaction_dbg(h, CLIXON_DBG_DETAIL, td, __FUNCTION__); /* Mark as changed in tree */ for (i=0; itd_dlen; i++){ /* Also down */ xn = td->td_dvec[i]; diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index 00e7a194..d69ebfad 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -972,6 +972,7 @@ xml_child_order(cxobj *xp, * xprev = x; * } * @endcode + * @note Assumes attributes are first in list * @see xml_child_index_each */ cxobj * @@ -990,8 +991,11 @@ xml_child_each(cxobj *xparent, xn = xparent->x_childvec[i]; if (xn == NULL) continue; - if (type != CX_ERROR && xml_type(xn) != type) + if (type != CX_ERROR && xml_type(xn) != type){ + if (type == CX_ATTR) /* Assume sorted attributes are first */ + return NULL; continue; + } break; /* this is next object after previous */ } if (i < xparent->x_childvec_len) /* found */