Skip to content

Commit a1d32af

Browse files
committed
Simplify pointer calculation in envadjust.
1 parent ad3b61f commit a1d32af

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/vm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ static inline void
118118
envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase)
119119
{
120120
mrb_callinfo *ci = mrb->c->cibase;
121+
ptrdiff_t off;
121122

122123
if (newbase == oldbase) return;
124+
off = newbase - oldbase;
123125
while (ci <= mrb->c->ci) {
124126
struct REnv *e = ci->env;
125127
if (e && MRB_ENV_STACK_SHARED_P(e)) {
126-
ptrdiff_t off = e->stack - oldbase;
127-
128-
e->stack = newbase + off;
128+
e->stack += off;
129129
}
130-
ci->stackent = newbase + (ci->stackent - oldbase);
130+
ci->stackent += off;
131131
ci++;
132132
}
133133
}

0 commit comments

Comments
 (0)