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

ruby-changes:40942

From: normal <ko1@a...>
Date: Thu, 10 Dec 2015 11:35:54 +0900 (JST)
Subject: [ruby-changes:40942] normal:r53021 (trunk): compile.c (iseq_compile_each): reduce needless rb_str_dup

normal	2015-12-10 11:35:22 +0900 (Thu, 10 Dec 2015)

  New Revision: 53021

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

  Log:
    compile.c (iseq_compile_each): reduce needless rb_str_dup
    
    There is no need to dup the fstring unless we want to set the
    debug ivar for it.
    
    [ruby-core:72018] <5668DB6E.8000101@r...>

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53020)
+++ ChangeLog	(revision 53021)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Dec 10 11:33:34 2015  Eric Wong  <e@8...>
+
+	* compile.c (iseq_compile_each): reduce needless rb_str_dup
+	  [ruby-core:72018] <5668DB6E.8000101@r...>
+
 Thu Dec 10 09:32:51 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/mkmf.rb, lib/shellwords.rb: disable frozen-string-literal.
Index: compile.c
===================================================================
--- compile.c	(revision 53020)
+++ compile.c	(revision 53021)
@@ -5339,16 +5339,16 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5339
 		ADD_INSN1(ret, line, putstring, node->nd_lit);
 	    }
 	    else {
-		VALUE str = rb_str_dup(node->nd_lit);
 		if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
 		    VALUE debug_info = rb_ary_new_from_args(2, iseq->body->location.path, INT2FIX(line));
+		    VALUE str = rb_str_dup(node->nd_lit);
 		    rb_ivar_set(str, id_debug_created_info, rb_obj_freeze(debug_info));
 		    ADD_INSN1(ret, line, putobject, rb_obj_freeze(str));
+		    iseq_add_mark_object_compile_time(iseq, str);
 		}
 		else {
-		    ADD_INSN1(ret, line, putobject, rb_fstring(str));
+		    ADD_INSN1(ret, line, putobject, node->nd_lit);
 		}
-		iseq_add_mark_object_compile_time(iseq, str);
 	    }
 	}
 	break;

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

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