From 4f566290d6abf6de3a4bd68d8e8c6f2440a79fdc Mon Sep 17 00:00:00 2001
From: Martin Karlgren <marty@roxen.com>
Date: Mon, 24 Oct 2016 09:59:51 +0200
Subject: [PATCH] map_delete: Match rehash test with new size calculation.

This avoids unnecessary rehashing that would occur on each m_delete in
a mapping having between x-(x/16)+8 and x entries, where x is any power of
2.
---
 src/mapping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mapping.c b/src/mapping.c
index 0628dfd839..c12be9e684 100644
--- a/src/mapping.c
+++ b/src/mapping.c
@@ -1186,7 +1186,7 @@ PMOD_EXPORT void map_delete_no_free(struct mapping *m,
 #endif
 
   if (!(md->flags & MAPPING_FLAG_NO_SHRINK)) {
-    if((md->size < md->hashsize * MIN_LINK_LENGTH) &&
+    if((MAP_SLOTS(md->size) < md->hashsize * MIN_LINK_LENGTH) &&
        (md->hashsize > AVG_LINK_LENGTH)) {
       debug_malloc_touch(m);
       rehash(m, MAP_SLOTS(m->data->size));
-- 
GitLab