From 65e63af377bb493dea4d0207627ed87d5da360a8 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 1 Jun 2019 13:15:43 +0900 Subject: Make opt_aref instruction support Integer#[] only when its receiver and the argument are both Integers. Since 6bedbf4625, Integer#[] has supported a range extraction. This means that Integer#[] now accepts multiple arguments, which made the method very slow unfortunately. This change fixes the performance issue by adding a special handling for its traditional use case: `num[idx]` where both `num` and `idx` are Integers. --- vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 3f5a619e3c..70ec2315c1 100644 --- a/vm.c +++ b/vm.c @@ -1643,7 +1643,7 @@ vm_init_redefined_flag(void) OP(GT, GT), (C(Integer), C(Float)); OP(GE, GE), (C(Integer), C(Float)); OP(LTLT, LTLT), (C(String), C(Array)); - OP(AREF, AREF), (C(Array), C(Hash)); + OP(AREF, AREF), (C(Array), C(Hash), C(Integer)); OP(ASET, ASET), (C(Array), C(Hash)); OP(Length, LENGTH), (C(Array), C(String), C(Hash)); OP(Size, SIZE), (C(Array), C(String), C(Hash)); -- cgit v1.2.3