ruby-changes:57660
From: Yusuke <ko1@a...>
Date: Sun, 8 Sep 2019 00:45:23 +0900 (JST)
Subject: [ruby-changes:57660] 86b74d1a73 (master): compile.c (compile_hash): Remove redundant check for NODE_ZLIST
https://git.ruby-lang.org/ruby.git/commit/?id=86b74d1a73 From 86b74d1a7389ceaccdc2822b1bbe0a91dc50db99 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Sun, 8 Sep 2019 00:11:50 +0900 Subject: 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. diff --git a/compile.c b/compile.c index 34cd858..0a69ecc 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 https://github.com/ruby/ruby/blob/trunk/compile.c#L4049 { 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 https://github.com/ruby/ruby/blob/trunk/compile.c#L7518 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; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/