diff options
author | Ilya Maximets <i.maximets@ovn.org> | 2022-08-29 22:52:45 +0200 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-08-30 23:51:05 +0200 |
commit | 5046f2e35f62838c2ad410e20448e0b7c81d8234 (patch) | |
tree | 5b8cfd884db10040c5807f2cbf5c48d04bcfbee0 /lib/hmapx.c | |
parent | a32a4e1fa2d3fad284834d4b7bccc2e71d33f9da (diff) | |
download | openvswitch-5046f2e35f62838c2ad410e20448e0b7c81d8234.tar.gz |
sset, smap, hmapx: Reserve hash map space while cloning.
This makes the clone a little bit faster by avoiding multiple
incremental expansions with re-allocations on big sets.
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib/hmapx.c')
-rw-r--r-- | lib/hmapx.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/hmapx.c b/lib/hmapx.c index 68192fc2c..bb9ec11c5 100644 --- a/lib/hmapx.c +++ b/lib/hmapx.c @@ -66,6 +66,8 @@ hmapx_clone(struct hmapx *map, const struct hmapx *orig) struct hmapx_node *node; hmapx_init(map); + hmap_reserve(&map->map, hmapx_count(orig)); + HMAP_FOR_EACH (node, hmap_node, &orig->map) { hmapx_add__(map, node->data, node->hmap_node.hash); } |