1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00

replace hashbrown with std hashmap

This commit is contained in:
Nikolay Kim 2019-12-04 18:32:18 +06:00
parent 0015a204aa
commit b45c6cd66b
10 changed files with 22 additions and 23 deletions

View File

@ -87,7 +87,7 @@ bytes = "0.4"
derive_more = "0.99.2"
encoding_rs = "0.8"
futures = "0.3.1"
hashbrown = "0.6.3"
fxhash = "0.2.1"
log = "0.4"
mime = "0.3"
net2 = "0.2.33"

View File

@ -64,7 +64,7 @@ derive_more = "0.99.2"
either = "1.5.2"
encoding_rs = "0.8"
futures = "0.3.1"
hashbrown = "0.6.3"
fxhash = "0.2.1"
h2 = "0.2.0-alpha.3"
http = "0.1.17"
httparse = "1.3"

View File

@ -12,8 +12,8 @@ use actix_service::Service;
use actix_utils::{oneshot, task::LocalWaker};
use bytes::Bytes;
use futures::future::{poll_fn, FutureExt, LocalBoxFuture};
use fxhash::FxHashMap;
use h2::client::{handshake, Connection, SendRequest};
use hashbrown::HashMap;
use http::uri::Authority;
use indexmap::IndexSet;
use slab::Slab;
@ -66,7 +66,7 @@ where
acquired: 0,
waiters: Slab::new(),
waiters_queue: IndexSet::new(),
available: HashMap::new(),
available: FxHashMap::default(),
waker: LocalWaker::new(),
})),
)
@ -259,7 +259,7 @@ pub(crate) struct Inner<Io> {
disconnect_timeout: Option<Duration>,
limit: usize,
acquired: usize,
available: HashMap<Key, VecDeque<AvailableConnection<Io>>>,
available: FxHashMap<Key, VecDeque<AvailableConnection<Io>>>,
waiters: Slab<
Option<(
Connect,

View File

@ -1,12 +1,12 @@
use std::any::{Any, TypeId};
use std::fmt;
use hashbrown::HashMap;
use fxhash::FxHashMap;
#[derive(Default)]
/// A type map of request extensions.
pub struct Extensions {
map: HashMap<TypeId, Box<dyn Any>>,
map: FxHashMap<TypeId, Box<dyn Any>>,
}
impl Extensions {
@ -14,7 +14,7 @@ impl Extensions {
#[inline]
pub fn new() -> Extensions {
Extensions {
map: HashMap::default(),
map: FxHashMap::default(),
}
}

View File

@ -1,6 +1,7 @@
use std::collections::hash_map::{self, Entry};
use either::Either;
use hashbrown::hash_map::{self, Entry};
use hashbrown::HashMap;
use fxhash::FxHashMap;
use http::header::{HeaderName, HeaderValue};
use http::HttpTryFrom;
@ -11,7 +12,7 @@ use http::HttpTryFrom;
/// [`HeaderName`]: struct.HeaderName.html
#[derive(Debug, Clone)]
pub struct HeaderMap {
pub(crate) inner: HashMap<HeaderName, Value>,
pub(crate) inner: FxHashMap<HeaderName, Value>,
}
#[derive(Debug, Clone)]
@ -56,7 +57,7 @@ impl HeaderMap {
/// allocate.
pub fn new() -> Self {
HeaderMap {
inner: HashMap::new(),
inner: FxHashMap::default(),
}
}
@ -70,7 +71,7 @@ impl HeaderMap {
/// More capacity than requested may be allocated.
pub fn with_capacity(capacity: usize) -> HeaderMap {
HeaderMap {
inner: HashMap::with_capacity(capacity),
inner: FxHashMap::with_capacity_and_hasher(capacity, Default::default()),
}
}

View File

@ -29,7 +29,6 @@ actix-service = "1.0.0-alpha.2"
bytes = "0.4"
derive_more = "0.99.2"
futures = "0.3.1"
hashbrown = "0.6.3"
serde = "1.0"
serde_json = "1.0"
time = "0.1.42"

View File

@ -43,12 +43,12 @@
//! }
//! ```
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use actix_web::dev::{Extensions, Payload, ServiceRequest, ServiceResponse};
use actix_web::{Error, FromRequest, HttpMessage, HttpRequest};
use futures::future::{ok, Ready};
use hashbrown::HashMap;
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde_json;

View File

@ -72,5 +72,4 @@ actix-server = { version = "1.0.0-alpha.2" }
brotli2 = { version="0.3.2" }
flate2 = { version="1.0.2" }
env_logger = "0.6"
rand = "0.7"
webpki = { version = "0.21" }

View File

@ -4,7 +4,7 @@ use std::task::{Context, Poll};
use actix_service::{Service, Transform};
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
use hashbrown::HashMap;
use fxhash::FxHashMap;
use crate::dev::{ServiceRequest, ServiceResponse};
use crate::error::{Error, Result};
@ -52,13 +52,13 @@ type ErrorHandler<B> = dyn Fn(ServiceResponse<B>) -> Result<ErrorHandlerResponse
/// # }
/// ```
pub struct ErrorHandlers<B> {
handlers: Rc<HashMap<StatusCode, Box<ErrorHandler<B>>>>,
handlers: Rc<FxHashMap<StatusCode, Box<ErrorHandler<B>>>>,
}
impl<B> Default for ErrorHandlers<B> {
fn default() -> Self {
ErrorHandlers {
handlers: Rc::new(HashMap::new()),
handlers: Rc::new(FxHashMap::default()),
}
}
}
@ -105,7 +105,7 @@ where
#[doc(hidden)]
pub struct ErrorHandlersMiddleware<S, B> {
service: S,
handlers: Rc<HashMap<StatusCode, Box<ErrorHandler<B>>>>,
handlers: Rc<FxHashMap<StatusCode, Box<ErrorHandler<B>>>>,
}
impl<S, B> Service for ErrorHandlersMiddleware<S, B>

View File

@ -2,7 +2,7 @@ use std::cell::RefCell;
use std::rc::Rc;
use actix_router::ResourceDef;
use hashbrown::HashMap;
use fxhash::FxHashMap;
use url::Url;
use crate::error::UrlGenerationError;
@ -12,7 +12,7 @@ use crate::request::HttpRequest;
pub struct ResourceMap {
root: ResourceDef,
parent: RefCell<Option<Rc<ResourceMap>>>,
named: HashMap<String, ResourceDef>,
named: FxHashMap<String, ResourceDef>,
patterns: Vec<(ResourceDef, Option<Rc<ResourceMap>>)>,
}
@ -21,7 +21,7 @@ impl ResourceMap {
ResourceMap {
root,
parent: RefCell::new(None),
named: HashMap::new(),
named: FxHashMap::default(),
patterns: Vec::new(),
}
}