Skip to content

BTreeMap::merge optimized#152418

Merged
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
asder8215:btreemap_merge_optimized
Feb 25, 2026
Merged

BTreeMap::merge optimized#152418
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
asder8215:btreemap_merge_optimized

Conversation

@asder8215
Copy link
Contributor

@asder8215 asder8215 commented Feb 10, 2026

This is an optimized version of #151981. See ACP and tracking issue for more information on BTreeMap::merge does.

CC @programmerjake. Let me know what you think of how I'm using CursorMut and IntoIter here and whether the unsafe code here looks good. I decided to use ptr::read() and ptr::write() to grab the value from CursorMut as V than &mut V, use it within the conflict function, and overwrite the content of conflicting key afterward.

I know this needs some polishing, especially with refactoring some redundant looking code in a nicer way, some of which could probably just be public API methods for CursorMut. It does pass all the tests that I currently have for BTreeMap::merge (inspired from BTreeMap::append) though, so that's good.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants