aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-05-25 19:49:41 +0000
committerMike Buland <eichlan@xagasoft.com>2012-05-25 19:49:41 +0000
commit8ff104489cf8eb6322bec90ebc8d66fedae665c9 (patch)
tree1dfd4fc3b82e94989aeb847dec054b97a7311016
parent0643b03b0ca30ef7c413a00bcd4eb17026dce568 (diff)
downloadlibbu++-8ff104489cf8eb6322bec90ebc8d66fedae665c9.tar.gz
libbu++-8ff104489cf8eb6322bec90ebc8d66fedae665c9.tar.bz2
libbu++-8ff104489cf8eb6322bec90ebc8d66fedae665c9.tar.xz
libbu++-8ff104489cf8eb6322bec90ebc8d66fedae665c9.zip
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.
Diffstat (limited to '')
-rw-r--r--src/stable/hash.h8
1 files changed, 7 insertions, 1 deletions
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
54 } 54 }
55 // This will hopefully prevent hash tables from growing needlessly 55 // This will hopefully prevent hash tables from growing needlessly
56 if( nFilled-nDeleted <= nCapacity/2 ) 56 if( nFilled-nDeleted <= nCapacity/2 )
57 return nCapacity; 57 {
58 if( nDeleted == 0 )
59 return nCapacity/4*5+1; // Grow just a little
60 else
61 return nCapacity; // We're going to delete things
62 }
58 // Otherwise, just increase the capacity 63 // Otherwise, just increase the capacity
59 return nCapacity*2+1; 64 return nCapacity*2+1;
60 } 65 }
@@ -306,6 +311,7 @@ namespace Bu
306 311
307 void reHash( uint32_t nNewSize ) 312 void reHash( uint32_t nNewSize )
308 { 313 {
314 //printf("--rehash: %d --> %d (%d, %d)\n", nCapacity, nNewSize, nFilled, nDeleted );
309 //printf("---REHASH---"); 315 //printf("---REHASH---");
310 //printf("Filled: %d, Deleted: %d, Capacity: %d\n", 316 //printf("Filled: %d, Deleted: %d, Capacity: %d\n",
311 // nFilled, nDeleted, nCapacity ); 317 // nFilled, nDeleted, nCapacity );