Skip to content

Commit

Permalink
Remove extraneous branch from push
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdn committed Nov 30, 2020
1 parent fc12fb1 commit 79f4132
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib.rs
Expand Up @@ -753,13 +753,15 @@ impl<A: Array> SmallVec<A> {
#[inline]
pub fn push(&mut self, value: A::Item) {
unsafe {
let (_, &mut len, cap) = self.triple_mut();
if len == cap {
let (mut ptr, mut len, cap) = self.triple_mut();
if *len == cap {
self.reserve(1);
let &mut (heap_ptr, ref mut heap_len) = self.data.heap_mut();
ptr = heap_ptr;
len = heap_len;
}
let (ptr, len_ptr, _) = self.triple_mut();
*len_ptr = len + 1;
ptr::write(ptr.add(len), value);
ptr::write(ptr.add(*len), value);
*len += 1;
}
}

Expand Down

0 comments on commit 79f4132

Please sign in to comment.