Changes in crates/runtime/src/map_ops.rs: #379
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
rust
technical-debt
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-seq!379
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "map.set-migration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Both follow the same SAFETY documentation pattern established in the list.push review.
PR Review: COW Fast Path for map.set and map.remove
The optimization is correct and follows the established list.push pattern well. Here are my findings:
ISSUES
Lines 30-31 in the module doc block still say the performance claim "Each mutation clones the underlying HashMap (O(n) for n entries)" - which is no longer universally true. Suggested update:
The inline Safety comment at the fast-path explains the Arc uniqueness check but does not note that once you have
&mut Value::Map(map)viaheap_value_mut, you already have&mut Box<HashMap>- and Box is always uniquely owned, so no second check is needed (unlike the Variant case which has a two-level Arc::get_mut). Worth adding a line for future readers.Every existing test creates a fresh map without dup-ing it, so only the fast path is exercised. Per the project's contributing guidelines ("complex logic has tests nearby"), tests for the slow path should be included. A minimal example: dup the map to create a second Arc reference, then verify the modified map has the new key AND the original map is unchanged. A mirror test for map_remove would complete the coverage.
The original doc said "If the key doesn't exist, returns the map unchanged." The new fast-path doc omits this. Both paths handle it identically (silent no-op), but a note would make the doc self-contained.
NITS
SUMMARY TABLE
Verdict: The optimization is correct. The two moderate gaps (slow-path test coverage) should be addressed before merge per the project's own contributing guidelines. The module doc update is a quick fix.
Generated with Claude Code