Repository navigation
feat(ts): drop a whole B-tree node by node as std's drop_tree does - #613
Conversation
Quest-Claim: cab9acc7dbc71cf4
The runtime's B-tree now holds std's node layout, so a whole map or set, dropped or cleared, drops each node's entries in order after its children's, as std's drop_tree walks it in postorder, rather than in key order. IntoIter still drops in key order, as std's dying_next does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p-order # Conflicts: # ts/fixtures/lang/collections/expected/collections.ts # ts/fixtures/lang/collections/expected/lib.ts # ts/fixtures/lang/collections/src/collections.rs # ts/fixtures/lang/collections/src/lib.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed head: c5bfba9db702e29940d413fb4a51b5ce3e46b8c9 against base b5f5545d06a0774204de7befb09b05bafaa1f1fc.
No actionable defects found. The new traversal drops child nodes left to right before each parent's key/value pairs, matching std's postorder drop_tree traversal. clear still empties the map before dropping its old contents, and IntoIter remains separate. I checked the generated fixtures and the paired Rust/TypeScript drop-order tests covering different tree shapes, sets, nested maps, and partial consumption. No code changes requested from this pass.
Limits: GitHub-only static review of all 13 changed files and relevant runtime/upstream code. I did not run translation, differential tests, the 120,000-step runtime test, benchmarks, or just ci. The PR's reported regression results and measurements were not independently reproduced; the visible Queue runs are skipped.
(Written by OpenAI)

Summary
std's
Drop for BTreeMap(at the pinned nightly-2026-10-15) callsdrop_tree(btree/navigate.rs). It walks the nodes in postorder and drops each node's entries in index order, so a parent's entries drop after its children's. Since moq-dev/rust2#577 ported std's node layout, the runtime can follow that walk exactly.rs.btreeDrop(glue for a wholeBTreeMaporBTreeSet, andclear) now does so instead of dropping in key order.IntoIter's drop stays in key order, as std'sdying_nextdoes.ts/runtime/rs/collections.ts:btreeDropwalks the tree in postorder (dropTree). Deletesflatten, which only this used.ts/README.md: the 2026-10-30 decision now covers only hash maps and sets. B-trees drop as std's do.collections::btree_dropslang case, ported from the reproduction in moq-dev/rust2#272. It builds whole trees of up to 297 logged values, to height 2, by random, ascending, and descending inserts,collect, removals and pops, sets, nested maps,IntoIterfrom both ends,clear, assignment,retainandsplit_off, andclone, then drops them. On main: 137 differences.btree_extractslang case and the task fixture'sdrops::orderscase 3 now drop their maps whole instead of working around the order throughinto_iter. On main: 352 task differences.btree_scriptintests/runtime.rs, the 120k-step random script against std'sBTreeMap, now hashes the drop order of every whole tree it discards (retain, extract, and collect drops, and split'sclear). Those trees reach about 20k entries. On main it fails at the first one.quest/m3/ts-btree-drop-order.mdand its link.Measurements
The bench's
btree/workloads holdu32entries, which have no drop glue, so they never callbtreeDropand cannot change. Instead, a node microbench ofbtreeDropwith a value dropper on 200 trees per size, old against new, two runs each:The new walk builds no intermediate arrays.
Public API
Translator output is unchanged. Only the runtime's
rs.btreeDropandrs.btreeClearchange order, for B-trees whose entries drop.Choices made without asking
Suggested follow-ups
None.
Review
Codex (
quest review), gpt-6.1-sol at medium effort, round 1 on headc5bfba9db702e29940d413fb4a51b5ce3e46b8c9againstorigin/mainb5f5545d0: no findings.(Written by Claude Opus 5.5)
🤖 Generated with Claude Code