@@ -7,7 +7,7 @@ struct hash_pair {
77 R_xlen_t value ;
88};
99struct hash_tab {
10- size_t size , free , mask ;
10+ size_t size , free ;
1111 int shift ;
1212 struct hash_pair * table ;
1313};
@@ -49,7 +49,6 @@ static hashtab * hash_create_(size_t n, double load_factor) {
4949 size_t n_full = get_full_size (n , load_factor );
5050 hashtab * ret = (hashtab * )R_alloc (sizeof (hashtab ), 1 );
5151 ret -> size = n_full ;
52- ret -> mask = n_full - 1 ;
5352 ret -> free = (size_t )(n_full * load_factor );
5453
5554 int k = 0 ;
@@ -78,8 +77,8 @@ static R_INLINE hashtab *hash_rehash(const hashtab *h) {
7877}
7978
8079static bool hash_set_ (hashtab * h , SEXP key , R_xlen_t value ) {
80+ size_t mask = h -> size - 1 ;
8181 size_t idx = hash_index (key , h -> shift );
82- size_t mask = h -> mask ;
8382 while (true) {
8483 if (!h -> table [idx ].key ) {
8584 if (h -> free == 0 ) return false; // table full -> need rehash
@@ -113,8 +112,8 @@ hashtab *hash_set_shared(hashtab *h, SEXP key, R_xlen_t value) {
113112}
114113
115114R_xlen_t hash_lookup (const hashtab * h , SEXP key , R_xlen_t ifnotfound ) {
115+ size_t mask = h -> size - 1 ;
116116 size_t idx = hash_index (key , h -> shift );
117- size_t mask = h -> mask ;
118117 while (true) {
119118 if (h -> table [idx ].key == key ) return h -> table [idx ].value ;
120119 if (h -> table [idx ].key == NULL ) return ifnotfound ;
0 commit comments