ruby-changes:49216
From: nobu <ko1@a...>
Date: Tue, 19 Dec 2017 11:41:40 +0900 (JST)
Subject: [ruby-changes:49216] nobu:r61331 (trunk): compile.c: pop splat result
nobu 2017-12-19 11:41:37 +0900 (Tue, 19 Dec 2017) New Revision: 61331 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61331 Log: compile.c: pop splat result * compile.c (compile_array): pop splat result without creating a new hash if the whole hash is popped. [ruby-core:84340] [Bug #14201] From: Nobuyoshi Nakada <nobu@r...> Modified files: trunk/compile.c Index: compile.c =================================================================== --- compile.c (revision 61330) +++ compile.c (revision 61331) @@ -3648,11 +3648,18 @@ compile_array(rb_iseq_t *iseq, LINK_ANCH https://github.com/ruby/ruby/blob/trunk/compile.c#L3648 } if (kw) { VALUE nhash = (i > 0 || !first) ? INT2FIX(2) : INT2FIX(1); - ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE)); - if (i > 0 || !first) ADD_INSN(ret, line, swap); + if (!popped) { + ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE)); + if (i > 0 || !first) ADD_INSN(ret, line, swap); + } COMPILE(ret, "keyword splat", kw); - ADD_SEND(ret, line, id_core_hash_merge_kwd, nhash); - if (nhash == INT2FIX(1)) ADD_SEND(ret, line, rb_intern("dup"), INT2FIX(0)); + if (popped) { + ADD_INSN(ret, line, pop); + } + else { + ADD_SEND(ret, line, id_core_hash_merge_kwd, nhash); + if (nhash == INT2FIX(1)) ADD_SEND(ret, line, rb_intern("dup"), INT2FIX(0)); + } } first = 0; break; @@ -3660,9 +3667,6 @@ compile_array(rb_iseq_t *iseq, LINK_ANCH https://github.com/ruby/ruby/blob/trunk/compile.c#L3667 APPEND_LIST(ret, anchor); break; } - if (popped) { - ADD_INSN(ret, line, pop); - } } else { /* popped */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/