mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Revert moving things to Ruby
This is slowing down benchmarks on x86, so lets revert it for now.
This commit is contained in:
parent
acbb8d4fb5
commit
2c1655314a
Notes:
git
2024-07-29 21:18:29 +00:00
6 changed files with 128 additions and 113 deletions
30
numeric.rb
30
numeric.rb
|
@ -241,36 +241,6 @@ class Integer
|
|||
self
|
||||
end
|
||||
|
||||
# call-seq:
|
||||
# downto(limit) {|i| ... } -> self
|
||||
# downto(limit) -> enumerator
|
||||
#
|
||||
# Calls the given block with each integer value from +self+ down to +limit+;
|
||||
# returns +self+:
|
||||
#
|
||||
# a = []
|
||||
# 10.downto(5) {|i| a << i } # => 10
|
||||
# a # => [10, 9, 8, 7, 6, 5]
|
||||
# a = []
|
||||
# 0.downto(-5) {|i| a << i } # => 0
|
||||
# a # => [0, -1, -2, -3, -4, -5]
|
||||
# 4.downto(5) {|i| fail 'Cannot happen' } # => 4
|
||||
#
|
||||
# With no block given, returns an Enumerator.
|
||||
def downto to
|
||||
Primitive.attr! :inline_block
|
||||
unless defined?(yield)
|
||||
return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 1, &to, int_downto_size)'
|
||||
end
|
||||
|
||||
from = self
|
||||
while from >= to
|
||||
yield from
|
||||
from = from.pred
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
# call-seq:
|
||||
# to_i -> self
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue