From 8ff104489cf8eb6322bec90ebc8d66fedae665c9 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 25 May 2012 19:49:41 +0000 Subject: Fixed a *very* rare steady-state issue in rehashing code. There's still potential for probing to fail in a way that can't be fixed by rehashing, but it should be amazingly rare. --- src/stable/hash.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stable/hash.h b/src/stable/hash.h index c7554a8..3bf12cb 100644 --- a/src/stable/hash.h +++ b/src/stable/hash.h @@ -54,7 +54,12 @@ namespace Bu } // This will hopefully prevent hash tables from growing needlessly if( nFilled-nDeleted <= nCapacity/2 ) - return nCapacity; + { + if( nDeleted == 0 ) + return nCapacity/4*5+1; // Grow just a little + else + return nCapacity; // We're going to delete things + } // Otherwise, just increase the capacity return nCapacity*2+1; } @@ -306,6 +311,7 @@ namespace Bu void reHash( uint32_t nNewSize ) { + //printf("--rehash: %d --> %d (%d, %d)\n", nCapacity, nNewSize, nFilled, nDeleted ); //printf("---REHASH---"); //printf("Filled: %d, Deleted: %d, Capacity: %d\n", // nFilled, nDeleted, nCapacity ); -- cgit v1.2.3