BTree: keep values off the function call stack while inserting#97350
BTree: keep values off the function call stack while inserting#97350ssomers wants to merge 1 commit intorust-lang:masterfrom ssomers:btree_offload_stack
Conversation
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
(rust-highfive has picked a reviewer for you, use r? to override) |
|
☔ The latest upstream changes (presumably #98091) made this pull request unmergeable. Please resolve the merge conflicts. |
|
☔ The latest upstream changes (presumably #98178) made this pull request unmergeable. Please resolve the merge conflicts. |
VacantEntry::insertreceives a value and returns a reference to the value's final location. Internally, it passes the value several levels down the stack, sneaks back a pointer to the place where the value was written, and converts that pointer to a reference at the last minute. I think it's actually safer and more efficient to not pass the value around, but only the location, and write the value there at the last minute.VacantEntry::insert(including your averageBTreeMap::insert) ensures the correct address is returned, whereas now there is only one unit test (intest_entry) superficially testing that the returned reference really points to the value.