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 <olivier.matz@6wind.com>
diff --git a/src/tree_data_hash.c b/src/tree_data_hash.c
index 65ece95..7235c27 100644
--- a/src/tree_data_hash.c
+++ b/src/tree_data_hash.c
@@ -182,8 +182,7 @@
}
}
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));