erofs-utils: lib: provide helper to disable hashmap shrinking
authorSandeep Dhavale <dhavale@google.com>
Thu, 23 May 2024 21:01:30 +0000 (14:01 -0700)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 4 Jun 2024 09:00:22 +0000 (17:00 +0800)
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@google.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240523210131.3126753-2-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
include/erofs/hashmap.h

index d25092d5081efc96d833fe1ddb6e5d68bbf846ad..484948eba8ad774766d8c26ec6e686e199b51744 100644 (file)
@@ -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)