mrblib: use yield instead of block.call for iteration methods

Replace block.call(x) with yield x in core iteration methods to take
advantage of the new OP_BLKCALL optimization. This improves Integer#times
by 13% and Array#each by 7%.

Methods updated:
- Integer#times, Integer#upto, Integer#downto
- Array#each, Array#each_index

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-01-22 08:55:15 +09:00
parent 52bee49ad2
commit 13bc858dff
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -17,7 +17,7 @@ class Array
idx = 0
while idx < length
block.call(self[idx])
yield self[idx]
idx += 1
end
self
@@ -37,7 +37,7 @@ class Array
idx = 0
while idx < length
block.call(idx)
yield idx
idx += 1
end
self
+3 -3
View File
@@ -49,7 +49,7 @@ class Integer
i = self.to_i
while i >= num
block.call(i)
yield i
i -= 1
end
self
@@ -74,7 +74,7 @@ class Integer
i = 0
while i < self
block.call(i)
yield i
i += 1
end
self
@@ -90,7 +90,7 @@ class Integer
i = self.to_i
while i <= num
block.call(i)
yield i
i += 1
end
self