Skip to content

Commit

Permalink
Revert "mem::swap, not mem::replace, in LRU backshifts"
Browse files Browse the repository at this point in the history
This reverts commit b7fbd04.
  • Loading branch information
workingjubilee committed Jan 4, 2025
1 parent b7fbd04 commit c88b038
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/symbolize/gimli/lru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ impl<T, const N: usize> Lru<T, N> {
let len_to_init = self.len + 1;
let mut last = MaybeUninit::new(value);
for elem in self.arr[0..len_to_init].iter_mut() {
mem::swap(elem, &mut last);
// OPT(size): using `mem::swap` allows surprising size regressions
last = mem::replace(elem, last);
}
self.len = len_to_init;

Expand All @@ -63,7 +64,8 @@ impl<T, const N: usize> Lru<T, N> {
// so it is permissible to allow the len invariant to decay, as we always restore it
let mut last = mem::replace(elem, MaybeUninit::uninit());
for elem in self.arr[0..=idx].iter_mut() {
mem::swap(elem, &mut last);
// OPT(size): using `mem::swap` allows surprising size regressions
last = mem::replace(elem, last);
}
self.arr
.first_mut()
Expand Down

0 comments on commit c88b038

Please sign in to comment.