diff --git a/CHANGELOG.md b/CHANGELOG.md index 5656a8c2..3835d18a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ Users may have to change how they access the system ### Corrected Bugs +* Fixed: Performance enhancement of unique list check (of duplicate keys) * Fixed: Validate/commit error with false positive yang choice changes detected in validation found in ietf-ipfix-psamp.yang. * Fixed: Accepted added subtrees containing lists with duplicate keys. * Fixed: [default state data returned with get-config](https://github.com/clicon/clixon/issues/140) diff --git a/lib/src/clixon_validate.c b/lib/src/clixon_validate.c index 74202415..4ec94914 100644 --- a/lib/src/clixon_validate.c +++ b/lib/src/clixon_validate.c @@ -585,29 +585,46 @@ check_mandatory(cxobj *xt, * @param[in] vec Vector of existing entries (new is last) * @param[in] i1 The new entry is placed at vec[i1] * @param[in] vlen Lenght of entry + * @param[in] sorted Sorted by system, ie sorted by key, otherwise no assumption * @retval 0 OK, entry is unique * @retval -1 Duplicate detected - * @note This is currently linear complexity. It could be improved by inserting new element sorted and binary search. + * @note This is currently quadratic complexity. It could be improved by inserting new element sorted and binary search. */ static int check_insert_duplicate(char **vec, int i1, - int vlen) + int vlen, + int sorted) { int i; int v; char *b; - - for (i=0; i