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>
This commit is contained in:
S.H 2021-06-05 13:57:21 +09:00 committed by GitHub
parent 033e76e760
commit 3208a5df2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2021-06-05 13:57:41 +09:00
Merged-By: k0kubun <takashikkbn@gmail.com>
5 changed files with 26 additions and 21 deletions

View file

@ -167,6 +167,26 @@ class Integer
return self
end
#
# 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
#
def size
Primitive.attr! 'inline'
Primitive.cexpr! 'rb_int_size(self)'
end
# call-seq:
# int.to_i -> integer
#