[PATCH 1/2] erofs-utils: lib: provide helper to disable hashmap shrinking

Sandeep Dhavale dhavale at google.com
Fri May 24 07:01:30 AEST 2024


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 <dhavale at google.com>
---
 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.45.1.288.g0e0cd299f1-goog



More information about the Linux-erofs mailing list