mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
replace hashbrown with std hashmap
This commit is contained in:
parent
0015a204aa
commit
b45c6cd66b
@ -87,7 +87,7 @@ bytes = "0.4"
|
|||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
hashbrown = "0.6.3"
|
fxhash = "0.2.1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
net2 = "0.2.33"
|
net2 = "0.2.33"
|
||||||
|
@ -64,7 +64,7 @@ derive_more = "0.99.2"
|
|||||||
either = "1.5.2"
|
either = "1.5.2"
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
hashbrown = "0.6.3"
|
fxhash = "0.2.1"
|
||||||
h2 = "0.2.0-alpha.3"
|
h2 = "0.2.0-alpha.3"
|
||||||
http = "0.1.17"
|
http = "0.1.17"
|
||||||
httparse = "1.3"
|
httparse = "1.3"
|
||||||
|
@ -12,8 +12,8 @@ use actix_service::Service;
|
|||||||
use actix_utils::{oneshot, task::LocalWaker};
|
use actix_utils::{oneshot, task::LocalWaker};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::{poll_fn, FutureExt, LocalBoxFuture};
|
use futures::future::{poll_fn, FutureExt, LocalBoxFuture};
|
||||||
|
use fxhash::FxHashMap;
|
||||||
use h2::client::{handshake, Connection, SendRequest};
|
use h2::client::{handshake, Connection, SendRequest};
|
||||||
use hashbrown::HashMap;
|
|
||||||
use http::uri::Authority;
|
use http::uri::Authority;
|
||||||
use indexmap::IndexSet;
|
use indexmap::IndexSet;
|
||||||
use slab::Slab;
|
use slab::Slab;
|
||||||
@ -66,7 +66,7 @@ where
|
|||||||
acquired: 0,
|
acquired: 0,
|
||||||
waiters: Slab::new(),
|
waiters: Slab::new(),
|
||||||
waiters_queue: IndexSet::new(),
|
waiters_queue: IndexSet::new(),
|
||||||
available: HashMap::new(),
|
available: FxHashMap::default(),
|
||||||
waker: LocalWaker::new(),
|
waker: LocalWaker::new(),
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
@ -259,7 +259,7 @@ pub(crate) struct Inner<Io> {
|
|||||||
disconnect_timeout: Option<Duration>,
|
disconnect_timeout: Option<Duration>,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
acquired: usize,
|
acquired: usize,
|
||||||
available: HashMap<Key, VecDeque<AvailableConnection<Io>>>,
|
available: FxHashMap<Key, VecDeque<AvailableConnection<Io>>>,
|
||||||
waiters: Slab<
|
waiters: Slab<
|
||||||
Option<(
|
Option<(
|
||||||
Connect,
|
Connect,
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use std::any::{Any, TypeId};
|
use std::any::{Any, TypeId};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use hashbrown::HashMap;
|
use fxhash::FxHashMap;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
/// A type map of request extensions.
|
/// A type map of request extensions.
|
||||||
pub struct Extensions {
|
pub struct Extensions {
|
||||||
map: HashMap<TypeId, Box<dyn Any>>,
|
map: FxHashMap<TypeId, Box<dyn Any>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Extensions {
|
impl Extensions {
|
||||||
@ -14,7 +14,7 @@ impl Extensions {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn new() -> Extensions {
|
pub fn new() -> Extensions {
|
||||||
Extensions {
|
Extensions {
|
||||||
map: HashMap::default(),
|
map: FxHashMap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
use std::collections::hash_map::{self, Entry};
|
||||||
|
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hashbrown::hash_map::{self, Entry};
|
use fxhash::FxHashMap;
|
||||||
use hashbrown::HashMap;
|
|
||||||
use http::header::{HeaderName, HeaderValue};
|
use http::header::{HeaderName, HeaderValue};
|
||||||
use http::HttpTryFrom;
|
use http::HttpTryFrom;
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ use http::HttpTryFrom;
|
|||||||
/// [`HeaderName`]: struct.HeaderName.html
|
/// [`HeaderName`]: struct.HeaderName.html
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct HeaderMap {
|
pub struct HeaderMap {
|
||||||
pub(crate) inner: HashMap<HeaderName, Value>,
|
pub(crate) inner: FxHashMap<HeaderName, Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -56,7 +57,7 @@ impl HeaderMap {
|
|||||||
/// allocate.
|
/// allocate.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
HeaderMap {
|
HeaderMap {
|
||||||
inner: HashMap::new(),
|
inner: FxHashMap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ impl HeaderMap {
|
|||||||
/// More capacity than requested may be allocated.
|
/// More capacity than requested may be allocated.
|
||||||
pub fn with_capacity(capacity: usize) -> HeaderMap {
|
pub fn with_capacity(capacity: usize) -> HeaderMap {
|
||||||
HeaderMap {
|
HeaderMap {
|
||||||
inner: HashMap::with_capacity(capacity),
|
inner: FxHashMap::with_capacity_and_hasher(capacity, Default::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ actix-service = "1.0.0-alpha.2"
|
|||||||
bytes = "0.4"
|
bytes = "0.4"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
hashbrown = "0.6.3"
|
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
time = "0.1.42"
|
time = "0.1.42"
|
||||||
|
@ -43,12 +43,12 @@
|
|||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use actix_web::dev::{Extensions, Payload, ServiceRequest, ServiceResponse};
|
use actix_web::dev::{Extensions, Payload, ServiceRequest, ServiceResponse};
|
||||||
use actix_web::{Error, FromRequest, HttpMessage, HttpRequest};
|
use actix_web::{Error, FromRequest, HttpMessage, HttpRequest};
|
||||||
use futures::future::{ok, Ready};
|
use futures::future::{ok, Ready};
|
||||||
use hashbrown::HashMap;
|
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
@ -72,5 +72,4 @@ actix-server = { version = "1.0.0-alpha.2" }
|
|||||||
brotli2 = { version="0.3.2" }
|
brotli2 = { version="0.3.2" }
|
||||||
flate2 = { version="1.0.2" }
|
flate2 = { version="1.0.2" }
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
rand = "0.7"
|
|
||||||
webpki = { version = "0.21" }
|
webpki = { version = "0.21" }
|
||||||
|
@ -4,7 +4,7 @@ use std::task::{Context, Poll};
|
|||||||
|
|
||||||
use actix_service::{Service, Transform};
|
use actix_service::{Service, Transform};
|
||||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||||
use hashbrown::HashMap;
|
use fxhash::FxHashMap;
|
||||||
|
|
||||||
use crate::dev::{ServiceRequest, ServiceResponse};
|
use crate::dev::{ServiceRequest, ServiceResponse};
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
@ -52,13 +52,13 @@ type ErrorHandler<B> = dyn Fn(ServiceResponse<B>) -> Result<ErrorHandlerResponse
|
|||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub struct ErrorHandlers<B> {
|
pub struct ErrorHandlers<B> {
|
||||||
handlers: Rc<HashMap<StatusCode, Box<ErrorHandler<B>>>>,
|
handlers: Rc<FxHashMap<StatusCode, Box<ErrorHandler<B>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B> Default for ErrorHandlers<B> {
|
impl<B> Default for ErrorHandlers<B> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
ErrorHandlers {
|
ErrorHandlers {
|
||||||
handlers: Rc::new(HashMap::new()),
|
handlers: Rc::new(FxHashMap::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ where
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub struct ErrorHandlersMiddleware<S, B> {
|
pub struct ErrorHandlersMiddleware<S, B> {
|
||||||
service: S,
|
service: S,
|
||||||
handlers: Rc<HashMap<StatusCode, Box<ErrorHandler<B>>>>,
|
handlers: Rc<FxHashMap<StatusCode, Box<ErrorHandler<B>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, B> Service for ErrorHandlersMiddleware<S, B>
|
impl<S, B> Service for ErrorHandlersMiddleware<S, B>
|
||||||
|
@ -2,7 +2,7 @@ use std::cell::RefCell;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use actix_router::ResourceDef;
|
use actix_router::ResourceDef;
|
||||||
use hashbrown::HashMap;
|
use fxhash::FxHashMap;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::error::UrlGenerationError;
|
use crate::error::UrlGenerationError;
|
||||||
@ -12,7 +12,7 @@ use crate::request::HttpRequest;
|
|||||||
pub struct ResourceMap {
|
pub struct ResourceMap {
|
||||||
root: ResourceDef,
|
root: ResourceDef,
|
||||||
parent: RefCell<Option<Rc<ResourceMap>>>,
|
parent: RefCell<Option<Rc<ResourceMap>>>,
|
||||||
named: HashMap<String, ResourceDef>,
|
named: FxHashMap<String, ResourceDef>,
|
||||||
patterns: Vec<(ResourceDef, Option<Rc<ResourceMap>>)>,
|
patterns: Vec<(ResourceDef, Option<Rc<ResourceMap>>)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ impl ResourceMap {
|
|||||||
ResourceMap {
|
ResourceMap {
|
||||||
root,
|
root,
|
||||||
parent: RefCell::new(None),
|
parent: RefCell::new(None),
|
||||||
named: HashMap::new(),
|
named: FxHashMap::default(),
|
||||||
patterns: Vec::new(),
|
patterns: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user