summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-19 02:41:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-19 02:41:37 +0000
commit23beb594568e25a65eb4f3d03f246f7f7ba79b84 (patch)
tree944ef03eba8c1560938d321a3f4c5655158ec656 /compile.c
parent0d09ee1e73d0cf0daed28acd75deeb12f09f42b6 (diff)
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@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/compile.c b/compile.c
index addf3be596..574a589dc8 100644
--- a/compile.c
+++ b/compile.c
@@ -3648,11 +3648,18 @@ 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;
@@ -3660,9 +3667,6 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro
APPEND_LIST(ret, anchor);
break;
}
- if (popped) {
- ADD_INSN(ret, line, pop);
- }
}
else {
/* popped */