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

ruby-changes:45819

From: nobu <ko1@a...>
Date: Sun, 12 Mar 2017 14:52:47 +0900 (JST)
Subject: [ruby-changes:45819] nobu:r57892 (trunk): compile.c: omit newhash

nobu	2017-03-12 14:52:42 +0900 (Sun, 12 Mar 2017)

  New Revision: 57892

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

  Log:
    compile.c: omit newhash
    
    * compile.c (iseq_compile_each): omit creating literal-only hash
      to be popped immediately.

  Modified files:
    trunk/compile.c
Index: compile.c
===================================================================
--- compile.c	(revision 57891)
+++ compile.c	(revision 57892)
@@ -5521,11 +5521,12 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L5521
 	INIT_ANCHOR(list);
 	switch (type) {
 	  case NODE_ARRAY:
-	    compile_array(iseq, list, node->nd_head, COMPILE_ARRAY_TYPE_HASH);
+	    compile_array_(iseq, list, node->nd_head, COMPILE_ARRAY_TYPE_HASH, NULL, popped);
 	    ADD_SEQ(ret, list);
 	    break;
 
 	  case NODE_ZARRAY:
+	    if (popped) break;
 	    ADD_INSN1(ret, line, newhash, INT2FIX(0));
 	    break;
 
@@ -5533,10 +5534,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L5534
 	    compile_bug(ERROR_ARGS_AT(node->nd_head) "can't make hash with this node: %s",
 			ruby_node_name(type));
 	}
-
-	if (popped) {
-	    ADD_INSN(ret, line, pop);
-	}
 	break;
       }
       case NODE_RETURN:{

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

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