summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-16 13:47:18 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-16 13:47:18 +0900
commit0bfa479c52963b95a47ceab3d453f21b646366a2 (patch)
tree39aa3bbc5434467d4a6d07e8db6778e1488965a0
parent07179c5c0fdee86650446aa373c3c2d5331600d6 (diff)
Split the optimizable range item conditions
-rw-r--r--compile.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 5800a6e8de..ace7a468e9 100644
--- a/compile.c
+++ b/compile.c
@@ -5180,7 +5180,15 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
static int
optimizable_range_item_p(const NODE *n)
{
- return (n && nd_type(n) == NODE_LIT && RB_INTEGER_TYPE_P(n->nd_lit)) || (n && nd_type(n) == NODE_NIL);
+ if (!n) return FALSE;
+ switch (nd_type(n)) {
+ case NODE_LIT:
+ return RB_INTEGER_TYPE_P(n->nd_lit);
+ case NODE_NIL:
+ return TRUE;
+ default:
+ return FALSE;
+ }
}
static int