From 3208a5df2dfb429752a130a36274464e9924cf44 Mon Sep 17 00:00:00 2001 From: "S.H" Date: Sat, 5 Jun 2021 13:57:21 +0900 Subject: Improve perfomance for Integer#size method [Feature #17135] (#3476) * Improve perfomance for Integer#size method [Feature #17135] * re-run ci * Let MJIT frame skip work for Integer#size Co-authored-by: Takashi Kokubun --- numeric.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index d0538ca126..b1425cad02 100644 --- a/numeric.c +++ b/numeric.c @@ -4715,30 +4715,14 @@ rb_int_abs(VALUE num) return Qnil; } -/* - * Document-method: Integer#size - * call-seq: - * int.size -> int - * - * Returns the number of bytes in the machine representation of +int+ - * (machine dependent). - * - * 1.size #=> 8 - * -1.size #=> 8 - * 2147483647.size #=> 8 - * (256**10 - 1).size #=> 10 - * (256**20 - 1).size #=> 20 - * (256**40 - 1).size #=> 40 - */ - static VALUE fix_size(VALUE fix) { return INT2FIX(sizeof(long)); } -static VALUE -int_size(VALUE num) +MJIT_FUNC_EXPORTED VALUE +rb_int_size(VALUE num) { if (FIXNUM_P(num)) { return fix_size(num); @@ -5458,7 +5442,6 @@ Init_Numeric(void) rb_define_method(rb_cInteger, "<<", rb_int_lshift, 1); rb_define_method(rb_cInteger, ">>", rb_int_rshift, 1); - rb_define_method(rb_cInteger, "size", int_size, 0); rb_define_method(rb_cInteger, "digits", rb_int_digits, -1); /* An obsolete class, use Integer */ -- cgit v1.2.3