Assume same alignment in RawVec
This commit is contained in:
parent
303ee3fd83
commit
46b547cb58
1 changed files with 6 additions and 1 deletions
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
use core::alloc::LayoutErr;
|
||||
use core::cmp;
|
||||
use core::intrinsics;
|
||||
use core::mem::{self, ManuallyDrop, MaybeUninit};
|
||||
use core::ops::Drop;
|
||||
use core::ptr::{NonNull, Unique};
|
||||
|
|
@ -495,7 +496,11 @@ where
|
|||
|
||||
let memory = if let Some((ptr, old_layout)) = current_memory {
|
||||
debug_assert_eq!(old_layout.align(), new_layout.align());
|
||||
unsafe { alloc.grow(ptr, old_layout, new_layout) }
|
||||
unsafe {
|
||||
// The allocator checks for alignment equality
|
||||
intrinsics::assume(old_layout.align() == new_layout.align());
|
||||
alloc.grow(ptr, old_layout, new_layout)
|
||||
}
|
||||
} else {
|
||||
alloc.alloc(new_layout)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue