diff options
| author | bors <bors@rust-lang.org> | 2021-03-12 23:27:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-12 23:27:23 +0000 |
| commit | 46a934a1dc789b9441e5fb5cd043287baddcc5c7 (patch) | |
| tree | e05f0ddb8a326faa2f523509471bf1564fb59988 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | b3e19a221e63dcffdef87e12eadf1f36a8b90295 (diff) | |
| parent | bf27819f37fb7cbe5fb67972d874ab285b741538 (diff) | |
| download | rust-46a934a1dc789b9441e5fb5cd043287baddcc5c7.tar.gz rust-46a934a1dc789b9441e5fb5cd043287baddcc5c7.zip | |
Auto merge of #83022 - m-ou-se:mem-replace-no-swap, r=nagisa
Don't implement mem::replace with mem::swap. `swap` is a complicated operation, so this changes the implementation of `replace` to use `read` and `write` instead. See https://github.com/rust-lang/rust/pull/83019. I wrote there: > Implementing the simpler operation (replace) with the much more complicated operation (swap) doesn't make a whole lot of sense. `replace` is just read+write, and the primitive for moving out of a `&mut`. `swap` is for doing that to *two* `&mut` at the same time, which is both more niche and more complicated (as shown by `swap_nonoverlapping_bytes`). This could be especially interesting for `Option<VeryLargeStruct>::take()`, since swapping such a large structure with `swap_nonoverlapping_bytes` is going to be much less efficient than `ptr::write()`'ing a `None`. But also for small values where `swap` just reads/writes using temporary variable, this makes a `replace` or `take` operation simpler: 
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
