Move Integer#downto to Ruby
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
This commit is contained in:
parent
beafae9750
commit
d57d85548f
Notes:
git
2024-11-13 20:27:44 +00:00
20
numeric.rb
20
numeric.rb
@ -321,6 +321,26 @@ class Integer
|
|||||||
def denominator
|
def denominator
|
||||||
1
|
1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
with_yjit do
|
||||||
|
if Primitive.rb_builtin_basic_definition_p(:downto)
|
||||||
|
undef :downto
|
||||||
|
|
||||||
|
def downto(to) # :nodoc:
|
||||||
|
Primitive.attr! :inline_block, :c_trace
|
||||||
|
|
||||||
|
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
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Float
|
class Float
|
||||||
|
Loading…
x
Reference in New Issue
Block a user