From 72a1eea3354767cb6fd22927cd18772e508fc635 Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Thu, 21 Sep 2023 08:53:59 +0200 Subject: [PATCH] tree_data OPTIMIZE optimize creation of children htable Here, we know the number of children that will be added in the hash table, so create the hash table with the correct number of elements to avoid automatic resizes. Signed-off-by: Olivier Matz --- src/tree_data_hash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tree_data_hash.c b/src/tree_data_hash.c index 65ece95c1..7235c27a3 100644 --- a/src/tree_data_hash.c +++ b/src/tree_data_hash.c @@ -182,8 +182,7 @@ lyd_insert_hash(struct lyd_node *node) } } if (u >= LYD_HT_MIN_ITEMS) { - /* create hash table, insert all the children */ - node->parent->children_ht = lyht_new(1, sizeof(struct lyd_node *), lyd_hash_table_val_equal, NULL, 1); + node->parent->children_ht = lyht_new(lyht_get_fixed_size(u), sizeof(struct lyd_node *), lyd_hash_table_val_equal, NULL, 1); LY_LIST_FOR(node->parent->child, iter) { if (iter->schema) { LY_CHECK_RET(lyd_insert_hash_add(node->parent->children_ht, iter, 1));