From e4c691b59db60ef2e6d8e64766d6ae02cd0dd457 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Tue, 14 Oct 2014 23:35:24 +0200 Subject: hashmap: introduce hashmap_reserve() With the current hashmap implementation that uses chaining, placing a reservation can serve two purposes: - To optimize putting of entries if the number of entries to put is known. The reservation allocates buckets, so later resizing can be avoided. - To avoid having very long bucket chains after using hashmap_move(_one). In an alternative hashmap implementation it will serve an additional purpose: - To guarantee a subsequent hashmap_move(_one) will not fail with -ENOMEM (this never happens in the current implementation). --- src/shared/set.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/shared/set.h') diff --git a/src/shared/set.h b/src/shared/set.h index 840ee0a7e4..8fe071a326 100644 --- a/src/shared/set.h +++ b/src/shared/set.h @@ -50,6 +50,7 @@ void *set_remove(Set *s, void *value); int set_remove_and_put(Set *s, void *old_value, void *new_value); int set_merge(Set *s, Set *other); +int set_reserve(Set *s, unsigned entries_add); void set_move(Set *s, Set *other); int set_move_one(Set *s, Set *other, void *value); -- cgit v1.2.3-54-g00ecf