mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-25 00:00:22 +02:00
Fix one use of MaybeUninit (#291)
This commit is contained in:
+3
-4
@@ -2176,19 +2176,18 @@ impl Inner {
|
|||||||
|
|
||||||
if self.is_inline_or_static() {
|
if self.is_inline_or_static() {
|
||||||
// In this case, a shallow_clone still involves copying the data.
|
// In this case, a shallow_clone still involves copying the data.
|
||||||
let mut inner: Inner = mem::MaybeUninit::uninit().assume_init();
|
let mut inner: mem::MaybeUninit<Inner> = mem::MaybeUninit::uninit();
|
||||||
ptr::copy_nonoverlapping(
|
ptr::copy_nonoverlapping(
|
||||||
self,
|
self,
|
||||||
&mut inner,
|
inner.as_mut_ptr(),
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
inner
|
inner.assume_init()
|
||||||
} else {
|
} else {
|
||||||
self.shallow_clone_sync(mut_self)
|
self.shallow_clone_sync(mut_self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cold]
|
#[cold]
|
||||||
unsafe fn shallow_clone_sync(&self, mut_self: bool) -> Inner {
|
unsafe fn shallow_clone_sync(&self, mut_self: bool) -> Inner {
|
||||||
// The function requires `&self`, this means that `shallow_clone`
|
// The function requires `&self`, this means that `shallow_clone`
|
||||||
|
|||||||
Reference in New Issue
Block a user