mirror of https://github.com/rust-lang/rust.git
cleanup
This commit is contained in:
parent
31e7990145
commit
9e9881bcd8
|
@ -168,15 +168,9 @@ impl<T, A: Allocator> RawVec<T, A> {
|
||||||
|
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
fn allocate_in(capacity: usize, init: AllocInit, alloc: A) -> Self {
|
fn allocate_in(capacity: usize, init: AllocInit, alloc: A) -> Self {
|
||||||
if mem::size_of::<T>() == 0 {
|
// Don't allocate here because `Drop` will not deallocate when `capacity` is 0.
|
||||||
|
if mem::size_of::<T>() == 0 || capacity == 0 {
|
||||||
Self::new_in(alloc)
|
Self::new_in(alloc)
|
||||||
} else if capacity == 0 {
|
|
||||||
// Don't allocate here because `Drop` will not deallocate when `capacity` is 0.
|
|
||||||
Self {
|
|
||||||
ptr: unsafe { Unique::new_unchecked(NonNull::dangling().as_ptr()) },
|
|
||||||
cap: capacity,
|
|
||||||
alloc,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// We avoid `unwrap_or_else` here because it bloats the amount of
|
// We avoid `unwrap_or_else` here because it bloats the amount of
|
||||||
// LLVM IR generated.
|
// LLVM IR generated.
|
||||||
|
|
Loading…
Reference in New Issue