lyds tree OPTIMIZE flag LYD_PARSE_ORDERED
1. When inserting, the last parameter can also be used for nodes
with lyds_tree
2. The principle of lyds_tree is that it is created lazily.
That is, if it is certain that the nodes are sorted, no metadata
or lyds_tree is created.
3. If it is necessary to modify the sorted nodes, the lyds_tree
is created additionally. This means that inserting the first node
can lead to a delay.
4. The LYD_PARSE_ORDERED flag now has a positive performance effect
because the lyds_tree is created lazily.
diff --git a/src/tree_data_free.c b/src/tree_data_free.c
index 188b52c..b1b48b3 100644
--- a/src/tree_data_free.c
+++ b/src/tree_data_free.c
@@ -273,12 +273,7 @@
return;
}
- /* get the first sibling */
- while (node->prev->next) {
- node = node->prev;
- }
-
- LY_LIST_FOR_SAFE(node, next, iter) {
+ LY_LIST_FOR_SAFE(lyd_first_sibling(node), next, iter) {
if (lysc_is_key(iter->schema) && iter->parent) {
LOGERR(LYD_CTX(iter), LY_EINVAL, "Cannot free a list key \"%s\", free the list instance instead.", LYD_NAME(iter));
return;