summaryrefslogtreecommitdiffhomepage
path: root/src/variable.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/variable.c')
-rw-r--r--src/variable.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/variable.c b/src/variable.c
index 2d3431e13..de740845b 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -78,16 +78,17 @@ iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val)
hash = kh_int_hash_func(mrb, sym);
start = pos = hash & (t->alloc-1);
for (;;) {
- if (keys[pos] == sym) {
+ mrb_sym key = keys[pos];
+ if (key == sym) {
vals[pos] = val;
return;
}
- else if (keys[pos] == IV_EMPTY) {
+ else if (key == IV_EMPTY) {
keys[pos] = sym;
vals[pos] = val;
return;
}
- else if (keys[pos] == IV_DELETED && dpos < 0) {
+ else if (key == IV_DELETED && dpos < 0) {
dpos = pos;
}
pos = (pos+1) & (t->alloc-1);
@@ -120,11 +121,12 @@ iv_get(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value *vp)
hash = kh_int_hash_func(mrb, sym);
start = pos = hash & (t->alloc-1);
for (;;) {
- if (keys[pos] == sym) {
+ mrb_sym key = keys[pos];
+ if (key == sym) {
if (vp) *vp = vals[pos];
return TRUE;
}
- else if (keys[pos] == IV_EMPTY) {
+ else if (key == IV_EMPTY) {
return FALSE;
}
pos = (pos+1) & (t->alloc-1);
@@ -148,12 +150,13 @@ iv_del(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value *vp)
hash = kh_int_hash_func(mrb, sym);
start = pos = hash & (t->alloc-1);
for (;;) {
- if (keys[pos] == sym) {
+ mrb_sym key = keys[pos];
+ if (key == sym) {
if (vp) *vp = vals[pos];
keys[pos] = IV_DELETED;
return TRUE;
}
- else if (keys[pos] == IV_EMPTY) {
+ else if (key == IV_EMPTY) {
return FALSE;
}
pos = (pos+1) & (t->alloc-1);