Repository navigation
Enumerable#zip: fast path only when every #each is built in (Greptile on #171) - #183
Conversation
#171 let Enumerable#zip read a non-Array argument with #each, after the receiver, when at most one of the receiver and the arguments had a custom #each. One is already too many (found by Greptile on #171, each case checked against CRuby 4.0.9): - A receiver's own #each can change an argument between its yields. MRI reads the argument in step, so `zip(h)` saw h[:a] before the change; IronRuby saw it after. - An argument's own #each, cut short with break, runs its ensure clauses where MRI's Enumerator#next leaves it suspended: an ensure that raised made (1..1).zip(src) raise, and the ensure ran at all. - A StopIteration raised by an argument's #each escaped instead of ending it with nils. The fast path now needs a built-in #each (Hash, Struct, Set, Integer Range) on the receiver and every argument; everything else goes through #next as before #171. Set#zip(Hash) keeps its speedup; a custom Enumerable argument is back on #next. Enumerable_ZipEnumerated1 gains the four cases; they fail on master's prelude. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 28 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Local full IronRuby.Tests (Debug net8.0) ran into its 25-minute timeout: the box was at load ~465 from other jobs. Its one failure, Greptile's P2 (CRLF → LF in ArrayTests.cs) was right: an edit script dropped the endings. Restored in 2nd commit; the diff is now 26+/5− in that file. |
Follow-up to #171 (part of #89). Greptile's two P1 comments on #171 hold against CRuby 4.0.9: the
Enumerable#zipfast path read the receiver to the end and then each argument with#each, and allowed one custom#eachamong them. One is already too many.eachsetsh[:a] = 9between yields,.zip(h)[[0, [:a, 1]], [1, [:b, 2]]][:a, 9]in row 1(1..1).zip(src),src.eachhas anensurethat raises[[1, 1]](1..2).zip(src),src.eachyields once, then raises StopIteration[[1, 1], [2, nil]](1..1).zip(src),src.eachlogs inensureArray#zipalready matched CRuby in all four (MRI'stake_itemsbreaks out of#eachtoo).Change: the fast path now needs a built-in
#each(Hash, Struct, Set, Integer Range) on the receiver and every argument; anything else goes through#next, as before #171.Set#zip(Hash)keeps its speedup (4 ms per 1000 elements, Debug); a custom Enumerable argument is back on#next. The second, now unused, branch of__zip_in_turn__is removed.Tests:
Enumerable_ZipEnumerated1gains the four cases (its expected output is CRuby's; the script's output is identical to CRuby 4.0.9's, and the new cases fail with master's prelude).Verified (Debug net8.0): ruby/spec core/enumerable, enumerator, array, hash, struct, set: 0 failures; the 3 errors in array/hash/struct are the known "into" wording ones and identical on master.
Enumerable_ZipEnumerated1passes on net10.0. Full IronRuby.Tests net8.0: see the comment below.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge.Summary
Enumerable#zipnow uses its fast path only when the receiver and every enumerated argument have a built-ineach.Reviews (2) · Last reviewed commit: "ArrayTests.cs: restore CRLF line endings..." · Reviewed by Greptile