Skip to content

Commit

Permalink
tree_data OPTIMIZE optimize creation of children htable
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
olivier-matz-6wind committed Sep 28, 2023
1 parent 9cc201e commit 8709d88
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/tree_data_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 8709d88

Please sign in to comment.