Skip to content

Commit 7c1cdb2

Browse files
HughParsonageaitap
authored andcommitted
Avoid setting same key&value twice
1 parent 2a1062f commit 7c1cdb2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/hash.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,17 @@ static bool hash_set_(hashtab *h, SEXP key, R_xlen_t value) {
111111
}
112112

113113
void hash_set(hashtab *h, SEXP key, R_xlen_t value) {
114-
if (!hash_set_(h, key, value))
114+
if (!hash_set_(h, key, value)) {
115115
*h = *hash_rehash(h);
116-
(void)hash_set_(h, key, value); // must succeed on the second try
116+
(void)hash_set_(h, key, value); // must succeed on the second try
117+
}
117118
}
118119

119120
hashtab *hash_set_shared(hashtab *h, SEXP key, R_xlen_t value) {
120-
if (!hash_set_(h, key, value))
121+
if (!hash_set_(h, key, value)) {
121122
h = hash_rehash(h);
122-
(void)hash_set_(h, key, value);
123+
(void)hash_set_(h, key, value);
124+
}
123125
return h;
124126
}
125127

0 commit comments

Comments
 (0)