diff --git a/src/symbolize/gimli/lru.rs b/src/symbolize/gimli/lru.rs index 37ba4a77..b7cf5a5b 100644 --- a/src/symbolize/gimli/lru.rs +++ b/src/symbolize/gimli/lru.rs @@ -46,7 +46,8 @@ impl Lru { 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; @@ -63,7 +64,8 @@ impl Lru { // 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()