From 1f9bf63cae2c5c71acf53416445b6d323fee9469 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Sun, 7 Nov 2010 23:06:03 +0100 Subject: [PATCH] When coercing the hash threshold to double, set up a minimum to avoid underflows --- src/c/hash.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/c/hash.d b/src/c/hash.d index fa464fc2e..57d12c3c3 100644 --- a/src/c/hash.d +++ b/src/c/hash.d @@ -509,6 +509,8 @@ do_clrhash(cl_object ht) } } +ecl_def_ct_single_float(min_threshold, 0.1, static, const); + cl_object cl__make_hash_table(cl_object test, cl_object size, cl_object rehash_size, cl_object rehash_threshold, cl_object lockable) @@ -594,10 +596,8 @@ cl__make_hash_table(cl_object test, cl_object size, cl_object rehash_size, h->hash.entries = 0; h->hash.rehash_size = rehash_size; h->hash.threshold = rehash_threshold; + rehash_threshold = cl_max(2, min_threshold, rehash_threshold); h->hash.factor = ecl_to_double(rehash_threshold); - if (h->hash.factor < 0.1) { - h->hash.factor = 0.1; - } h->hash.limit = h->hash.size * h->hash.factor; h->hash.data = NULL; /* for GC sake */ h->hash.data = (struct ecl_hashtable_entry *)