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

ruby-changes:25183

From: ko1 <ko1@a...>
Date: Wed, 17 Oct 2012 08:42:26 +0900 (JST)
Subject: [ruby-changes:25183] ko1:r37235 (trunk): * compile.c (compile_dstr_fragments): use `putobject' instead of

ko1	2012-10-17 08:38:58 +0900 (Wed, 17 Oct 2012)

  New Revision: 37235

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

  Log:
    * compile.c (compile_dstr_fragments): use `putobject' instead of
      `putstring' for all of strings used by NODE_DSTR because
      ruby users can not grab this string.
      For example, the string object of "baz" in "foo#{bar}baz"
      is located by `putobject' (users can not touch "baz" object
      directly). This change reduces GC pressure.
      This improvement is suggested by Aaron Patterson.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37234)
+++ ChangeLog	(revision 37235)
@@ -1,3 +1,13 @@
+Wed Oct 17 08:32:46 2012  Koichi Sasada  <ko1@a...>
+
+	* compile.c (compile_dstr_fragments): use `putobject' instead of
+	  `putstring' for all of strings used by NODE_DSTR because
+	  ruby users can not grab this string.
+	  For example, the string object of "baz" in "foo#{bar}baz"
+	  is located by `putobject' (users can not touch "baz" object
+	  directly). This change reduces GC pressure.
+	  This improvement is suggested by Aaron Patterson.
+
 Wed Oct 17 08:02:57 2012  Koichi Sasada  <ko1@a...>
 
 	* thread.c (rb_threadptr_interrupt_mask): fix to check interrupt
Index: compile.c
===================================================================
--- compile.c	(revision 37234)
+++ compile.c	(revision 37235)
@@ -2215,10 +2215,8 @@
     return COMPILE_OK;
 }
 
-
-
 static int
-compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int *cntp)
+compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *node, int *cntp)
 {
     NODE *list = node->nd_next;
     VALUE lit = node->nd_lit;
@@ -2232,7 +2230,14 @@
     }
 
     while (list) {
-	COMPILE(ret, "each string", list->nd_head);
+	node = list->nd_head;
+	if (nd_type(node) == NODE_STR) {
+	    hide_obj(node->nd_lit);
+	    ADD_INSN1(ret, nd_line(node), putobject, node->nd_lit);
+	}
+	else {
+	    COMPILE(ret, "each string", node);
+	}
 	cnt++;
 	list = list->nd_next;
     }

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

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