From 0bfa479c52963b95a47ceab3d453f21b646366a2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 16 Feb 2020 13:47:18 +0900 Subject: Split the optimizable range item conditions --- compile.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'compile.c') 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 -- cgit v1.2.3