summaryrefslogtreecommitdiff
path: root/src/ht.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ht.c')
-rw-r--r--src/ht.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ht.c b/src/ht.c
index 45953f4..770eff6 100644
--- a/src/ht.c
+++ b/src/ht.c
@@ -3,7 +3,7 @@
#include <stdio.h>
#include "ht.h"
-#define HT_REHASH_THRESHOLD 0.5
+#define HT_REHASH_THRESHOLD 0.7
P_ATTR
static NUM
@@ -171,7 +171,10 @@ destroy_ht(ht * restrict htp, HT_DESTROY_FLAG flag)
static BOOL
ht_expand(ht *htp)
{
- htp->capability <<= 1;
+ UNUM newcap = htp->capability << 1;
+
+ if (newcap < htp->capability + (1 << 20)) htp->capability = newcap;
+ else htp->capability = htp->capability + (1 << 20);
void **keys = NULL;
NUM size = htp->size;