summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-09-08 00:11:50 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-09-08 00:28:03 +0900
commit86b74d1a7389ceaccdc2822b1bbe0a91dc50db99 (patch)
treed9c906360a07b150c61577d89f7a2112c3b084bd
parent050f67c9c634fc0064c49f79ecb49588676028ec (diff)
compile.c (compile_hash): Remove redundant check for NODE_ZLIST
NODE_ZLIST case is handled in compile_hash, so iseq_compile_each0 doesn't have to do the same check redundantly.
-rw-r--r--compile.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/compile.c b/compile.c
index 34cd858ba6..0a69ecc5f3 100644
--- a/compile.c
+++ b/compile.c
@@ -4049,7 +4049,9 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popp
{
int line = (int)nd_line(node);
- if (nd_type(node) == NODE_ZLIST) {
+ node = node->nd_head;
+
+ if (!node || nd_type(node) == NODE_ZLIST) {
if (!popped) {
ADD_INSN1(ret, line, newhash, INT2FIX(0));
}
@@ -7516,29 +7518,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_INSN1(ret, line, newarray, INT2FIX(node->nd_alen));
break;
}
- case NODE_HASH:{
- DECL_ANCHOR(list);
- enum node_type type = node->nd_head ? nd_type(node->nd_head) : NODE_ZLIST;
-
- INIT_ANCHOR(list);
- switch (type) {
- case NODE_LIST:
- CHECK(compile_hash(iseq, list, node->nd_head, popped) >= 0);
- ADD_SEQ(ret, list);
- break;
-
- case NODE_ZLIST:
- if (popped) break;
- ADD_INSN1(ret, line, newhash, INT2FIX(0));
- break;
-
- default:
- COMPILE_ERROR(ERROR_ARGS_AT(node->nd_head) "can't make hash with this node: %s",
- ruby_node_name(type));
- goto ng;
- }
- break;
- }
+ case NODE_HASH:
+ CHECK(compile_hash(iseq, ret, node, popped) >= 0);
+ break;
case NODE_RETURN:
CHECK(compile_return(iseq, ret, node, popped));
break;