mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
* 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:
parent
033e76e760
commit
3208a5df2d
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
20
numeric.rb
20
numeric.rb
|
@ -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
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue