summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorS.H <gamelinks007@gmail.com>2021-06-05 13:57:21 +0900
committerGitHub <noreply@github.com>2021-06-04 21:57:21 -0700
commit3208a5df2dfb429752a130a36274464e9924cf44 (patch)
tree9fb96fe83aa888d54f9c57290c66c26ef4630d2e /numeric.c
parent033e76e7602d06e037e1d9bb8527280a58d548da (diff)
downloadruby-3208a5df2dfb429752a130a36274464e9924cf44.tar.gz
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 <takashikkbn@gmail.com>
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c21
1 files changed, 2 insertions, 19 deletions
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 */