libyang FEATURE sorting of data nodes
1. Plugin type 'lyds_tree' is integrated. Used in metadata and it is
internal, which is distinguished by the unset print callback.
Internal metadata must not be printed.
2. Leaf-list and list data instances are now automatically sorted.
3. Both the explicit and implicit YANG statement 'ordered-by system'
will cause the nodes to be ordered.
4. The first instance of the list or leaf-list of node contain
new metadata named 'lyds_tree'.
5. Data nodes are sorted only if their data types have
callback 'sort' set.
6. Sorting can be turned off so far only by adding the 'ordered-by user'
statement to the YANG model.
7. If the sort fails for some reason, the node is still inserted
as the last instance. A warning message informs about this situation.
8. The time required for sorting should be relatively small thanks to
the Red-black tree implementation.
9. Memory requirements will now increase by 40 bytes per list/leaf-list
data node, plus metadata structure overhead.
10. New internal lyds_tree plugin type.
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index d0b3431..360e351 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -2700,12 +2700,15 @@
/* list ordering */
if (node->nodetype & (LYS_LIST | LYS_LEAFLIST)) {
if ((node->flags & (LYS_CONFIG_R | LYS_IS_OUTPUT | LYS_IS_NOTIF)) && (node->flags & LYS_ORDBY_MASK)) {
+ node->flags &= ~LYS_ORDBY_MASK;
LOGVRB("The ordered-by statement is ignored in lists representing %s (%s).",
(node->flags & LYS_IS_OUTPUT) ? "RPC/action output parameters" :
(ctx->compile_opts & LYS_IS_NOTIF) ? "notification content" : "state data", ctx->path);
- node->flags &= ~LYS_ORDBY_MASK;
- node->flags |= LYS_ORDBY_SYSTEM;
- } else if (!(node->flags & LYS_ORDBY_MASK)) {
+ }
+ if (node->flags & (LYS_IS_OUTPUT | LYS_IS_NOTIF)) {
+ /* it is probably better not to order them */
+ node->flags |= LYS_ORDBY_USER;
+ } else if (!(node->flags & LYS_ORDBY_MASK) || (node->flags & LYS_CONFIG_R)) {
/* default ordering is system */
node->flags |= LYS_ORDBY_SYSTEM;
}