summaryrefslogtreecommitdiff
path: root/src/shared/hashmap.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-01 00:13:18 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-01 00:17:21 +0200
commit45fa9e29f8c9759c8f2f4238fed956f695c73dc3 (patch)
tree456b6168141128bd35319af35ac9e437851680b1 /src/shared/hashmap.h
parentbcd8e6d1bd3f434af894faeb400fee0e99445a7f (diff)
hashmap: size hashmap bucket array dynamically
Instead of fixing the hashmap bucket array to 127 entries dynamically size it, starting with a smaller one of 31. As soon as a fill level of 75% is reached, quadruple the size, and so on. This should siginficantly optimize the lookup time in large tables (from O(n) back to O(1)), and save memory on smaller tables (which most are).
Diffstat (limited to 'src/shared/hashmap.h')
-rw-r--r--src/shared/hashmap.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/shared/hashmap.h b/src/shared/hashmap.h
index 15b7e27585..3d4f6721bc 100644
--- a/src/shared/hashmap.h
+++ b/src/shared/hashmap.h
@@ -76,6 +76,7 @@ int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key);
unsigned hashmap_size(Hashmap *h) _pure_;
bool hashmap_isempty(Hashmap *h) _pure_;
+unsigned hashmap_buckets(Hashmap *h) _pure_;
void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key);
void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key);