aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--vm_insnhelper.c20
2 files changed, 19 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 44119f85f7..89c65da9cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Feb 24 19:09:25 2015 Koichi Sasada <ko1@atdot.net>
+
+ * vm_insnhelper.c (lep_svar_place, lep_svar_get): do not create
+ additional T_NODE object (svars holder) when only getting
+ svars.
+
Tue Feb 24 11:49:48 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* time.c (time_zone_name): should be US-ASCII only if all 7-bits,
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: