Skip to content

Commit 48684ed

Browse files
committed
remove mask from struct
1 parent 5832041 commit 48684ed

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/hash.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct hash_pair {
77
R_xlen_t value;
88
};
99
struct 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

8079
static 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

115114
R_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

Comments
 (0)