1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-01-31 11:02:08 +01:00

use ahash for internal hashmaps

This commit is contained in:
Rob Ede 2021-01-04 04:29:07 +00:00
parent 2d4a174420
commit 007a145988
No known key found for this signature in database
GPG Key ID: C2A3B36E841A91E6
3 changed files with 8 additions and 8 deletions

View File

@ -87,12 +87,12 @@ actix-web-codegen = "0.4.0"
actix-http = "2.2.0" actix-http = "2.2.0"
awc = { version = "2.0.3", default-features = false } awc = { version = "2.0.3", default-features = false }
ahash = "0.6"
bytes = "1" bytes = "1"
derive_more = "0.99.5" derive_more = "0.99.5"
encoding_rs = "0.8" encoding_rs = "0.8"
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 } futures-util = { version = "0.3.7", default-features = false }
fxhash = "0.2.1"
log = "0.4" log = "0.4"
mime = "0.3" mime = "0.3"
socket2 = "0.3.16" socket2 = "0.3.16"

View File

@ -4,7 +4,7 @@ use std::task::{Context, Poll};
use actix_service::{Service, Transform}; use actix_service::{Service, Transform};
use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready}; use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready};
use fxhash::FxHashMap; use ahash::AHashMap;
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<FxHashMap<StatusCode, Box<ErrorHandler<B>>>>, handlers: Rc<AHashMap<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(FxHashMap::default()), handlers: Rc::new(AHashMap::default()),
} }
} }
} }
@ -104,7 +104,7 @@ where
#[doc(hidden)] #[doc(hidden)]
pub struct ErrorHandlersMiddleware<S, B> { pub struct ErrorHandlersMiddleware<S, B> {
service: S, service: S,
handlers: Rc<FxHashMap<StatusCode, Box<ErrorHandler<B>>>>, handlers: Rc<AHashMap<StatusCode, Box<ErrorHandler<B>>>>,
} }
impl<S, B> Service<ServiceRequest> for ErrorHandlersMiddleware<S, B> impl<S, B> Service<ServiceRequest> for ErrorHandlersMiddleware<S, B>

View File

@ -2,7 +2,7 @@ use std::cell::RefCell;
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
use actix_router::ResourceDef; use actix_router::ResourceDef;
use fxhash::FxHashMap; use ahash::AHashMap;
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<Weak<ResourceMap>>, parent: RefCell<Weak<ResourceMap>>,
named: FxHashMap<String, ResourceDef>, named: AHashMap<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(Weak::new()), parent: RefCell::new(Weak::new()),
named: FxHashMap::default(), named: AHashMap::default(),
patterns: Vec::new(), patterns: Vec::new(),
} }
} }