mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-03 21:07:39 +03:00
Remove .assume_init usage #106
This commit is contained in:
parent
ce6a77b326
commit
851d3b970f
3 changed files with 17 additions and 9 deletions
|
@ -1,5 +1,9 @@
|
|||
# Changes
|
||||
|
||||
## [0.1.15] (2022-05-05)
|
||||
|
||||
* Remove .assume_init usage #106
|
||||
|
||||
## [0.1.14] (2022-02-06)
|
||||
|
||||
* Restore Buf impl for Cursor
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "ntex-bytes"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
license = "MIT"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>", "Carl Lerche <me@carllerche.com>"]
|
||||
description = "Types and traits for working with bytes (bytes crate fork)"
|
||||
|
|
|
@ -2961,10 +2961,12 @@ impl Inner {
|
|||
|
||||
#[inline]
|
||||
unsafe fn from_ptr_inline(src: *const u8, len: usize) -> Inner {
|
||||
// Using uninitialized memory is ~30% faster
|
||||
#[allow(invalid_value, clippy::uninit_assumed_init)]
|
||||
let mut inner: Inner = mem::MaybeUninit::uninit().assume_init();
|
||||
inner.arc = NonNull::new_unchecked(KIND_INLINE as *mut Shared);
|
||||
let mut inner = Inner {
|
||||
arc: NonNull::new_unchecked(KIND_INLINE as *mut Shared),
|
||||
ptr: ptr::null_mut(),
|
||||
len: 0,
|
||||
cap: 0,
|
||||
};
|
||||
|
||||
let dst = inner.inline_ptr();
|
||||
ptr::copy(src, dst, len);
|
||||
|
@ -3094,10 +3096,12 @@ impl Inner {
|
|||
#[inline]
|
||||
fn to_inline(&self) -> Inner {
|
||||
unsafe {
|
||||
// Using uninitialized memory is ~30% faster
|
||||
#[allow(invalid_value, clippy::uninit_assumed_init)]
|
||||
let mut inner: Inner = mem::MaybeUninit::uninit().assume_init();
|
||||
inner.arc = NonNull::new_unchecked(KIND_INLINE as *mut Shared);
|
||||
let mut inner = Inner {
|
||||
arc: NonNull::new_unchecked(KIND_INLINE as *mut Shared),
|
||||
ptr: ptr::null_mut(),
|
||||
cap: 0,
|
||||
len: 0,
|
||||
};
|
||||
let len = self.len();
|
||||
inner.as_raw()[..len].copy_from_slice(self.as_ref());
|
||||
inner.set_inline_len(len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue