File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ struct hash_tab {
1616//
1717static const double hash_multiplier1 = 0.618033988749895 ;
1818static const double hash_multiplier2 = 0.316227766016838 ;
19+ static const double default_load_factor = .5 ;
1920
2021static R_INLINE size_t get_full_size (size_t n_elements , double load_factor ) {
2122 if (load_factor <= 0 || load_factor >= 1 )
@@ -61,7 +62,7 @@ static hashtab * hash_create_(size_t n, double load_factor) {
6162 return ret ;
6263}
6364
64- hashtab * hash_create (size_t n ) { return hash_create_ (n , .5 ); }
65+ hashtab * hash_create (size_t n ) { return hash_create_ (n , default_load_factor ); }
6566
6667// double hashing
6768static R_INLINE size_t hash_index1 (SEXP key , uintptr_t multiplier ) {
@@ -82,7 +83,7 @@ static R_INLINE size_t hash_index2(SEXP key, uintptr_t multiplier) {
8283
8384void hash_rehash (hashtab * h ) {
8485 size_t new_size = h -> size * 2 ;
85- hashtab * new_h = hash_create_ (new_size , 0.5 );
86+ hashtab * new_h = hash_create_ (new_size , default_load_factor );
8687
8788 for (size_t i = 0 ; i < h -> size ; ++ i ) {
8889 if (h -> table [i ].key ) hash_set (new_h , h -> table [i ].key , h -> table [i ].value );
You can’t perform that action at this time.
0 commit comments