aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-06-01 13:15:43 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-06-01 13:15:43 +0900
commit65e63af377bb493dea4d0207627ed87d5da360a8 (patch)
tree06871344ac6e5800a9c06387d52f2ce942c04609 /numeric.c
parent7df65ef67691fcc354d819da9cd54a1ade9b6247 (diff)
downloadruby-65e63af377bb493dea4d0207627ed87d5da360a8.tar.gz
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.
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/numeric.c b/numeric.c
index 336ff7066a..1fce19ac0b 100644
--- a/numeric.c
+++ b/numeric.c
@@ -4630,8 +4630,8 @@ rb_int_rshift(VALUE x, VALUE y)
return Qnil;
}
-static VALUE
-fix_aref(VALUE fix, VALUE idx)
+MJIT_FUNC_EXPORTED VALUE
+rb_fix_aref(VALUE fix, VALUE idx)
{
long val = FIX2LONG(fix);
long i;
@@ -4722,7 +4722,7 @@ int_aref1(VALUE num, VALUE arg)
one_bit:
if (FIXNUM_P(num)) {
- return fix_aref(num, arg);
+ return rb_fix_aref(num, arg);
}
else if (RB_TYPE_P(num, T_BIGNUM)) {
return rb_big_aref(num, arg);