mirror of https://github.com/fafhrd91/actix-web
use faster ahash maps
This commit is contained in:
parent
a919d2de56
commit
22749150ae
|
@ -58,7 +58,7 @@ encoding_rs = "0.8"
|
||||||
futures-channel = { version = "0.3.7", default-features = false }
|
futures-channel = { version = "0.3.7", default-features = false }
|
||||||
futures-core = { version = "0.3.7", default-features = false }
|
futures-core = { version = "0.3.7", default-features = false }
|
||||||
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }
|
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }
|
||||||
fxhash = "0.2.1"
|
ahash = "0.6"
|
||||||
h2 = "0.3.0"
|
h2 = "0.3.0"
|
||||||
http = "0.2.2"
|
http = "0.2.2"
|
||||||
httparse = "1.3"
|
httparse = "1.3"
|
||||||
|
|
|
@ -13,7 +13,7 @@ use actix_utils::task::LocalWaker;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures_channel::oneshot;
|
use futures_channel::oneshot;
|
||||||
use futures_util::future::{poll_fn, FutureExt, LocalBoxFuture};
|
use futures_util::future::{poll_fn, FutureExt, LocalBoxFuture};
|
||||||
use fxhash::FxHashMap;
|
use ahash::AHashMap;
|
||||||
use h2::client::{Connection, SendRequest};
|
use h2::client::{Connection, SendRequest};
|
||||||
use http::uri::Authority;
|
use http::uri::Authority;
|
||||||
use indexmap::IndexSet;
|
use indexmap::IndexSet;
|
||||||
|
@ -59,7 +59,7 @@ where
|
||||||
acquired: 0,
|
acquired: 0,
|
||||||
waiters: Slab::new(),
|
waiters: Slab::new(),
|
||||||
waiters_queue: IndexSet::new(),
|
waiters_queue: IndexSet::new(),
|
||||||
available: FxHashMap::default(),
|
available: AHashMap::default(),
|
||||||
waker: LocalWaker::new(),
|
waker: LocalWaker::new(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ struct AvailableConnection<Io> {
|
||||||
pub(crate) struct Inner<Io> {
|
pub(crate) struct Inner<Io> {
|
||||||
config: ConnectorConfig,
|
config: ConnectorConfig,
|
||||||
acquired: usize,
|
acquired: usize,
|
||||||
available: FxHashMap<Key, VecDeque<AvailableConnection<Io>>>,
|
available: AHashMap<Key, VecDeque<AvailableConnection<Io>>>,
|
||||||
waiters: Slab<
|
waiters: Slab<
|
||||||
Option<(
|
Option<(
|
||||||
Connect,
|
Connect,
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
use std::any::{Any, TypeId};
|
use std::{
|
||||||
use std::{fmt, mem};
|
any::{Any, TypeId},
|
||||||
|
fmt, mem,
|
||||||
|
};
|
||||||
|
|
||||||
use fxhash::FxHashMap;
|
use ahash::AHashMap;
|
||||||
|
|
||||||
/// A type map of request extensions.
|
/// A type map of request extensions.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Extensions {
|
pub struct Extensions {
|
||||||
/// Use FxHasher with a std HashMap with for faster
|
/// Use FxHasher with a std HashMap with for faster
|
||||||
/// lookups on the small `TypeId` (u64 equivalent) keys.
|
/// lookups on the small `TypeId` (u64 equivalent) keys.
|
||||||
map: FxHashMap<TypeId, Box<dyn Any>>,
|
map: AHashMap<TypeId, Box<dyn Any>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Extensions {
|
impl Extensions {
|
||||||
|
@ -16,7 +18,7 @@ impl Extensions {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new() -> Extensions {
|
pub fn new() -> Extensions {
|
||||||
Extensions {
|
Extensions {
|
||||||
map: FxHashMap::default(),
|
map: AHashMap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use std::collections::hash_map::{self, Entry};
|
use std::{collections::hash_map::{self, Entry}, convert::TryFrom};
|
||||||
use std::convert::TryFrom;
|
|
||||||
|
|
||||||
|
use ahash::AHashMap;
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use fxhash::FxHashMap;
|
|
||||||
use http::header::{HeaderName, HeaderValue};
|
use http::header::{HeaderName, HeaderValue};
|
||||||
|
|
||||||
/// A set of HTTP headers
|
/// A set of HTTP headers
|
||||||
|
@ -10,7 +9,7 @@ use http::header::{HeaderName, HeaderValue};
|
||||||
/// `HeaderMap` is an multi-map of [`HeaderName`] to values.
|
/// `HeaderMap` is an multi-map of [`HeaderName`] to values.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct HeaderMap {
|
pub struct HeaderMap {
|
||||||
pub(crate) inner: FxHashMap<HeaderName, Value>,
|
pub(crate) inner: AHashMap<HeaderName, Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -55,7 +54,7 @@ impl HeaderMap {
|
||||||
/// allocate.
|
/// allocate.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
HeaderMap {
|
HeaderMap {
|
||||||
inner: FxHashMap::default(),
|
inner: AHashMap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +68,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: FxHashMap::with_capacity_and_hasher(capacity, Default::default()),
|
inner: AHashMap::with_capacity_and_hasher(capacity, Default::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
//! Various http headers
|
//! Various HTTP headers.
|
||||||
// This is mostly copy of [hyper](https://github.com/hyperium/hyper/tree/master/src/header)
|
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
use std::{convert::TryFrom, fmt, str::FromStr};
|
||||||
use std::{fmt, str::FromStr};
|
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use http::Error as HttpError;
|
use http::Error as HttpError;
|
||||||
|
|
Loading…
Reference in New Issue