fixing an incredible edge case
this basically only happens if the Vc oscilates between 7 and 8 elemenst Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
parent
a1e692eac7
commit
04680c8b7c
|
@ -381,25 +381,26 @@ impl Vc {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push(&mut self, value: Nid) {
|
pub fn push(&mut self, value: Nid) {
|
||||||
if let Some(layout) = self.layout()
|
if let Some(layout) = self.layout() {
|
||||||
&& unsafe { self.alloced.len == self.alloced.cap }
|
if unsafe { self.alloced.len == self.alloced.cap } {
|
||||||
{
|
unsafe {
|
||||||
unsafe {
|
self.alloced.cap *= 2;
|
||||||
self.alloced.cap *= 2;
|
self.alloced.base = Unique::new_unchecked(
|
||||||
self.alloced.base = Unique::new_unchecked(
|
alloc::realloc(
|
||||||
alloc::realloc(
|
self.alloced.base.as_ptr().cast(),
|
||||||
self.alloced.base.as_ptr().cast(),
|
layout,
|
||||||
layout,
|
self.alloced.cap as usize * core::mem::size_of::<Nid>(),
|
||||||
self.alloced.cap as usize * core::mem::size_of::<Nid>(),
|
)
|
||||||
)
|
.cast(),
|
||||||
.cast(),
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
} else if self.len() == INLINE_ELEMS {
|
} else if self.len() == INLINE_ELEMS {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut allcd =
|
let mut allcd =
|
||||||
Self::alloc((self.inline.cap + 1).next_power_of_two() as _, self.len());
|
Self::alloc((self.inline.cap + 1).next_power_of_two() as _, self.len());
|
||||||
core::ptr::copy_nonoverlapping(self.as_ptr(), allcd.as_mut_ptr(), self.len());
|
core::ptr::copy_nonoverlapping(self.as_ptr(), allcd.as_mut_ptr(), self.len());
|
||||||
|
debug_assert!(!allcd.is_inline());
|
||||||
*self = allcd;
|
*self = allcd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue