Making and dropping an empty `BTreeMap` is not free.
Open
@jakedrew is already working on this.
Since Aug 19, 2026.
A-collections
C-optimization
S-has-bisection
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
https://godbolt.org/z/v594PEsr7
I expected to see this happen:
ret
Instead, this happened:
example[7a9efb3d937417e2]::drop_btree:
push r14
push rbx
sub rsp, 104
mov qword ptr [rsp + 32], 0
mov qword ptr [rsp + 64], 0
mov qword ptr [rsp + 96], 0
lea rdi, [rsp + 8]
lea rsi, [rsp + 32]
call <alloc[c00562a4ff4db933]::collections::btree::map::IntoIter<(), ()>>::dying_next
cmp qword ptr [rsp + 8], 0
je .LBB0_3
lea rbx, [rsp + 8]
lea r14, [rsp + 32]
.LBB0_2:
mov rdi, rbx
mov rsi, r14
call <alloc[c00562a4ff4db933]::collections::btree::map::IntoIter<(), ()>>::dying_next
cmp qword ptr [rsp + 8], 0
jne .LBB0_2
.LBB0_3:
add rsp, 104
pop rbx
pop r14
ret
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.