mirror of
https://github.com/actix/actix-web.git
synced 2024-11-19 16:11:07 +00:00
Remove mem::uninitialized()
(#1090)
This commit is contained in:
parent
a32573bb58
commit
c1f99e0775
4 changed files with 11 additions and 8 deletions
|
@ -212,7 +212,7 @@ where
|
||||||
pub fn finish(
|
pub fn finish(
|
||||||
self,
|
self,
|
||||||
) -> impl Service<Request = Connect, Response = impl Connection, Error = ConnectError>
|
) -> impl Service<Request = Connect, Response = impl Connection, Error = ConnectError>
|
||||||
+ Clone {
|
+ Clone {
|
||||||
#[cfg(not(any(feature = "ssl", feature = "rust-tls")))]
|
#[cfg(not(any(feature = "ssl", feature = "rust-tls")))]
|
||||||
{
|
{
|
||||||
let connector = TimeoutService::new(
|
let connector = TimeoutService::new(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
use std::io;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::{io, mem};
|
use std::mem::MaybeUninit;
|
||||||
|
|
||||||
use actix_codec::Decoder;
|
use actix_codec::Decoder;
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
|
@ -186,11 +187,12 @@ impl MessageType for Request {
|
||||||
fn decode(src: &mut BytesMut) -> Result<Option<(Self, PayloadType)>, ParseError> {
|
fn decode(src: &mut BytesMut) -> Result<Option<(Self, PayloadType)>, ParseError> {
|
||||||
// Unsafe: we read only this data only after httparse parses headers into.
|
// Unsafe: we read only this data only after httparse parses headers into.
|
||||||
// performance bump for pipeline benchmarks.
|
// performance bump for pipeline benchmarks.
|
||||||
let mut headers: [HeaderIndex; MAX_HEADERS] = unsafe { mem::uninitialized() };
|
let mut headers: [HeaderIndex; MAX_HEADERS] =
|
||||||
|
unsafe { MaybeUninit::uninit().assume_init() };
|
||||||
|
|
||||||
let (len, method, uri, ver, h_len) = {
|
let (len, method, uri, ver, h_len) = {
|
||||||
let mut parsed: [httparse::Header; MAX_HEADERS] =
|
let mut parsed: [httparse::Header; MAX_HEADERS] =
|
||||||
unsafe { mem::uninitialized() };
|
unsafe { MaybeUninit::uninit().assume_init() };
|
||||||
|
|
||||||
let mut req = httparse::Request::new(&mut parsed);
|
let mut req = httparse::Request::new(&mut parsed);
|
||||||
match req.parse(src)? {
|
match req.parse(src)? {
|
||||||
|
@ -260,11 +262,12 @@ impl MessageType for ResponseHead {
|
||||||
fn decode(src: &mut BytesMut) -> Result<Option<(Self, PayloadType)>, ParseError> {
|
fn decode(src: &mut BytesMut) -> Result<Option<(Self, PayloadType)>, ParseError> {
|
||||||
// Unsafe: we read only this data only after httparse parses headers into.
|
// Unsafe: we read only this data only after httparse parses headers into.
|
||||||
// performance bump for pipeline benchmarks.
|
// performance bump for pipeline benchmarks.
|
||||||
let mut headers: [HeaderIndex; MAX_HEADERS] = unsafe { mem::uninitialized() };
|
let mut headers: [HeaderIndex; MAX_HEADERS] =
|
||||||
|
unsafe { MaybeUninit::uninit().assume_init() };
|
||||||
|
|
||||||
let (len, ver, status, h_len) = {
|
let (len, ver, status, h_len) = {
|
||||||
let mut parsed: [httparse::Header; MAX_HEADERS] =
|
let mut parsed: [httparse::Header; MAX_HEADERS] =
|
||||||
unsafe { mem::uninitialized() };
|
unsafe { MaybeUninit::uninit().assume_init() };
|
||||||
|
|
||||||
let mut res = httparse::Response::new(&mut parsed);
|
let mut res = httparse::Response::new(&mut parsed);
|
||||||
match res.parse(src)? {
|
match res.parse(src)? {
|
||||||
|
|
|
@ -115,7 +115,7 @@ pub fn write_content_length(mut n: usize, bytes: &mut BytesMut) {
|
||||||
|
|
||||||
pub(crate) fn convert_usize(mut n: usize, bytes: &mut BytesMut) {
|
pub(crate) fn convert_usize(mut n: usize, bytes: &mut BytesMut) {
|
||||||
let mut curr: isize = 39;
|
let mut curr: isize = 39;
|
||||||
let mut buf: [u8; 41] = unsafe { mem::uninitialized() };
|
let mut buf: [u8; 41] = unsafe { mem::MaybeUninit::uninit().assume_init() };
|
||||||
buf[39] = b'\r';
|
buf[39] = b'\r';
|
||||||
buf[40] = b'\n';
|
buf[40] = b'\n';
|
||||||
let buf_ptr = buf.as_mut_ptr();
|
let buf_ptr = buf.as_mut_ptr();
|
||||||
|
|
|
@ -150,7 +150,7 @@ impl TestRequest {
|
||||||
|
|
||||||
/// Complete request creation and generate `Request` instance
|
/// Complete request creation and generate `Request` instance
|
||||||
pub fn finish(&mut self) -> Request {
|
pub fn finish(&mut self) -> Request {
|
||||||
let inner = self.0.take().expect("cannot reuse test request builder");;
|
let inner = self.0.take().expect("cannot reuse test request builder");
|
||||||
|
|
||||||
let mut req = if let Some(pl) = inner.payload {
|
let mut req = if let Some(pl) = inner.payload {
|
||||||
Request::with_payload(pl)
|
Request::with_payload(pl)
|
||||||
|
|
Loading…
Reference in a new issue