aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index ad8c30441c..1f477650ce 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -139,7 +139,7 @@ rb_error_arity(int argc, int min, int max)
/* svar */
-static inline NODE *
+static inline NODE **
lep_svar_place(rb_thread_t *th, VALUE *lep)
{
VALUE *svar;
@@ -150,16 +150,17 @@ lep_svar_place(rb_thread_t *th, VALUE *lep)
else {
svar = &th->root_svar;
}
- if (NIL_P(*svar)) {
- *svar = (VALUE)NEW_IF(Qnil, Qnil, Qnil);
- }
- return (NODE *)*svar;
+
+ return (NODE **)svar;
}
static VALUE
lep_svar_get(rb_thread_t *th, VALUE *lep, rb_num_t key)
{
- NODE *svar = lep_svar_place(th, lep);
+ NODE **svar_place = lep_svar_place(th, lep);
+ NODE *svar = *svar_place;
+
+ if (NIL_P((VALUE)svar)) return Qnil;
switch (key) {
case 0:
@@ -182,7 +183,12 @@ lep_svar_get(rb_thread_t *th, VALUE *lep, rb_num_t key)
static void
lep_svar_set(rb_thread_t *th, VALUE *lep, rb_num_t key, VALUE val)
{
- NODE *svar = lep_svar_place(th, lep);
+ NODE **svar_place = lep_svar_place(th, lep);
+ NODE *svar = *svar_place;
+
+ if (NIL_P((VALUE)svar)) {
+ svar = *svar_place = NEW_IF(Qnil, Qnil, Qnil);
+ }
switch (key) {
case 0: