From dae73ca91c6d723fe45c82bee2fe1bc3bc4be307 Mon Sep 17 00:00:00 2001 From: Sandeep Dhavale Date: Thu, 23 May 2024 14:01:30 -0700 Subject: [PATCH] erofs-utils: lib: provide helper to disable hashmap shrinking This helper sets hasmap.shrink_at to 0. This is helpful to iterate over hashmap using hashmap_iter_next() and use hashmap_remove() in single pass efficeintly. Signed-off-by: Sandeep Dhavale Reviewed-by: Gao Xiang Link: https://lore.kernel.org/r/20240523210131.3126753-2-dhavale@google.com Signed-off-by: Gao Xiang --- include/erofs/hashmap.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/erofs/hashmap.h b/include/erofs/hashmap.h index d25092d..484948e 100644 --- a/include/erofs/hashmap.h +++ b/include/erofs/hashmap.h @@ -97,6 +97,10 @@ static inline void *hashmap_iter_first(struct hashmap *map, return hashmap_iter_next(iter); } +static inline void hashmap_disable_shrink(struct hashmap * map) +{ + map->shrink_at = 0; +} /* string interning */ const void *memintern(const void *data, size_t len); static inline const char *strintern(const char *string) -- 2.34.1