Skip to content

Commit

Permalink
compile.c: pop splat result
Browse files Browse the repository at this point in the history
* 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@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Dec 19, 2017
1 parent 0d09ee1 commit 23beb59
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions compile.c
Expand Up @@ -3648,21 +3648,25 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro
}
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;
case COMPILE_ARRAY_TYPE_ARGS:
APPEND_LIST(ret, anchor);
break;
}
if (popped) {
ADD_INSN(ret, line, pop);
}
}
else {
/* popped */
Expand Down

0 comments on commit 23beb59

Please sign in to comment.