mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-23 16:21:06 +01:00
refactor: replace ahash with foldhash
This commit is contained in:
parent
049b49290d
commit
2eef58e741
@ -106,12 +106,12 @@ actix-codec = "0.5"
|
|||||||
actix-utils = "3"
|
actix-utils = "3"
|
||||||
actix-rt = { version = "2.2", default-features = false }
|
actix-rt = { version = "2.2", default-features = false }
|
||||||
|
|
||||||
ahash = "0.8"
|
|
||||||
bitflags = "2"
|
bitflags = "2"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
bytestring = "1"
|
bytestring = "1"
|
||||||
derive_more = { version = "1", features = ["as_ref", "deref", "deref_mut", "display", "error", "from"] }
|
derive_more = { version = "1", features = ["as_ref", "deref", "deref_mut", "display", "error", "from"] }
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
|
foldhash = "0.1"
|
||||||
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
||||||
http = "0.2.7"
|
http = "0.2.7"
|
||||||
httparse = "1.5.1"
|
httparse = "1.5.1"
|
||||||
|
@ -31,7 +31,7 @@ impl Hasher for NoOpHasher {
|
|||||||
/// All entries into this map must be owned types (or static references).
|
/// All entries into this map must be owned types (or static references).
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Extensions {
|
pub struct Extensions {
|
||||||
/// Use AHasher with a std HashMap with for faster lookups on the small `TypeId` keys.
|
// use no-op hasher with a std HashMap with for faster lookups on the small `TypeId` keys
|
||||||
map: HashMap<TypeId, Box<dyn Any>, BuildHasherDefault<NoOpHasher>>,
|
map: HashMap<TypeId, Box<dyn Any>, BuildHasherDefault<NoOpHasher>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
//! A multi-value [`HeaderMap`] and its iterators.
|
//! A multi-value [`HeaderMap`] and its iterators.
|
||||||
|
|
||||||
use std::{borrow::Cow, collections::hash_map, iter, ops};
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
|
collections::{hash_map, HashMap},
|
||||||
|
iter, ops,
|
||||||
|
};
|
||||||
|
|
||||||
use ahash::AHashMap;
|
use foldhash::HashMap as FoldHashMap;
|
||||||
use http::header::{HeaderName, HeaderValue};
|
use http::header::{HeaderName, HeaderValue};
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
|
|
||||||
@ -47,7 +51,7 @@ use super::AsHeaderName;
|
|||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct HeaderMap {
|
pub struct HeaderMap {
|
||||||
pub(crate) inner: AHashMap<HeaderName, Value>,
|
pub(crate) inner: FoldHashMap<HeaderName, Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A bespoke non-empty list for HeaderMap values.
|
/// A bespoke non-empty list for HeaderMap values.
|
||||||
@ -116,7 +120,10 @@ impl HeaderMap {
|
|||||||
/// ```
|
/// ```
|
||||||
pub fn with_capacity(capacity: usize) -> Self {
|
pub fn with_capacity(capacity: usize) -> Self {
|
||||||
HeaderMap {
|
HeaderMap {
|
||||||
inner: AHashMap::with_capacity(capacity),
|
inner: HashMap::with_capacity_and_hasher(
|
||||||
|
capacity,
|
||||||
|
foldhash::fast::RandomState::default(),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,13 +141,13 @@ actix-http = { version = "3.7", features = ["ws"] }
|
|||||||
actix-router = { version = "0.5.3", default-features = false, features = ["http"] }
|
actix-router = { version = "0.5.3", default-features = false, features = ["http"] }
|
||||||
actix-web-codegen = { version = "4.3", optional = true, default-features = false }
|
actix-web-codegen = { version = "4.3", optional = true, default-features = false }
|
||||||
|
|
||||||
ahash = "0.8"
|
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
bytestring = "1"
|
bytestring = "1"
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
cookie = { version = "0.16", features = ["percent-encode"], optional = true }
|
cookie = { version = "0.16", features = ["percent-encode"], optional = true }
|
||||||
derive_more = { version = "1", features = ["display", "error", "from"] }
|
derive_more = { version = "1", features = ["display", "error", "from"] }
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
|
foldhash = "0.1"
|
||||||
futures-core = { version = "0.3.17", default-features = false }
|
futures-core = { version = "0.3.17", default-features = false }
|
||||||
futures-util = { version = "0.3.17", default-features = false }
|
futures-util = { version = "0.3.17", default-features = false }
|
||||||
itoa = "1"
|
itoa = "1"
|
||||||
|
@ -8,7 +8,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use actix_service::{Service, Transform};
|
use actix_service::{Service, Transform};
|
||||||
use ahash::AHashMap;
|
use foldhash::HashMap as FoldHashMap;
|
||||||
use futures_core::{future::LocalBoxFuture, ready};
|
use futures_core::{future::LocalBoxFuture, ready};
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ pub struct ErrorHandlers<B> {
|
|||||||
handlers: Handlers<B>,
|
handlers: Handlers<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type Handlers<B> = Rc<AHashMap<StatusCode, Box<ErrorHandler<B>>>>;
|
type Handlers<B> = Rc<FoldHashMap<StatusCode, Box<ErrorHandler<B>>>>;
|
||||||
|
|
||||||
impl<B> Default for ErrorHandlers<B> {
|
impl<B> Default for ErrorHandlers<B> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
@ -6,7 +6,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use actix_router::ResourceDef;
|
use actix_router::ResourceDef;
|
||||||
use ahash::AHashMap;
|
use foldhash::HashMap as FoldHashMap;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{error::UrlGenerationError, request::HttpRequest};
|
use crate::{error::UrlGenerationError, request::HttpRequest};
|
||||||
@ -19,7 +19,7 @@ pub struct ResourceMap {
|
|||||||
|
|
||||||
/// Named resources within the tree or, for external resources, it points to isolated nodes
|
/// Named resources within the tree or, for external resources, it points to isolated nodes
|
||||||
/// outside the tree.
|
/// outside the tree.
|
||||||
named: AHashMap<String, Rc<ResourceMap>>,
|
named: FoldHashMap<String, Rc<ResourceMap>>,
|
||||||
|
|
||||||
parent: RefCell<Weak<ResourceMap>>,
|
parent: RefCell<Weak<ResourceMap>>,
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ impl ResourceMap {
|
|||||||
pub fn new(root: ResourceDef) -> Self {
|
pub fn new(root: ResourceDef) -> Self {
|
||||||
ResourceMap {
|
ResourceMap {
|
||||||
pattern: root,
|
pattern: root,
|
||||||
named: AHashMap::default(),
|
named: FoldHashMap::default(),
|
||||||
parent: RefCell::new(Weak::new()),
|
parent: RefCell::new(Weak::new()),
|
||||||
nodes: Some(Vec::new()),
|
nodes: Some(Vec::new()),
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ impl ResourceMap {
|
|||||||
} else {
|
} else {
|
||||||
let new_node = Rc::new(ResourceMap {
|
let new_node = Rc::new(ResourceMap {
|
||||||
pattern: pattern.clone(),
|
pattern: pattern.clone(),
|
||||||
named: AHashMap::default(),
|
named: FoldHashMap::default(),
|
||||||
parent: RefCell::new(Weak::new()),
|
parent: RefCell::new(Weak::new()),
|
||||||
nodes: None,
|
nodes: None,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user