[前][次][番号順一覧][スレッド一覧]

ruby-changes:37640

From: ko1 <ko1@a...>
Date: Tue, 24 Feb 2015 19:11:27 +0900 (JST)
Subject: [ruby-changes:37640] ko1:r49721 (trunk): * vm_insnhelper.c (lep_svar_place, lep_svar_get): do not create

ko1	2015-02-24 19:11:14 +0900 (Tue, 24 Feb 2015)

  New Revision: 49721

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49721

  Log:
    * vm_insnhelper.c (lep_svar_place, lep_svar_get): do not create
      additional T_NODE object (svars holder) when only getting
      svars.

  Modified files:
    trunk/ChangeLog
    trunk/vm_insnhelper.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49720)
+++ ChangeLog	(revision 49721)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Feb 24 19:09:25 2015  Koichi Sasada  <ko1@a...>
+
+	* 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@r...>
 
 	* time.c (time_zone_name): should be US-ASCII only if all 7-bits,
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 49720)
+++ vm_insnhelper.c	(revision 49721)
@@ -139,7 +139,7 @@ rb_error_arity(int argc, int min, int ma https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L139
 
 /* 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 *l https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L150
     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 https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L183
 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:

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]