From e65cd393b5dfe28d8efb118707a94188b22a6992 Mon Sep 17 00:00:00 2001 From: Andras Mocsary Date: Sun, 3 Nov 2019 20:00:35 +0100 Subject: [PATCH] Use Ahash --- actix-http/Cargo.toml | 2 ++ actix-http/src/client/pool.rs | 4 +++- actix-http/src/extensions.rs | 4 +++- actix-http/src/header/map.rs | 7 +++++-- actix-session/src/lib.rs | 3 ++- src/rmap.rs | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 581dc2cd4..d0beafe55 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -54,6 +54,7 @@ actix-utils = "0.4.4" actix-server-config = "0.1.2" actix-threadpool = "0.1.1" +ahash = { version = "0.2", features = ["std"] } base64 = "0.10" bitflags = "1.0" bytes = "0.4" @@ -62,6 +63,7 @@ derive_more = "0.15.0" either = "1.5.2" encoding_rs = "0.8" futures = "0.1.25" +hashbrown = "0.6.0" h2 = "0.1.16" http = "0.1.17" httparse = "1.3" diff --git a/actix-http/src/client/pool.rs b/actix-http/src/client/pool.rs index f4af3fde3..a4f7a283d 100644 --- a/actix-http/src/client/pool.rs +++ b/actix-http/src/client/pool.rs @@ -12,7 +12,9 @@ use futures::task::AtomicTask; use futures::unsync::oneshot; use futures::{Async, Future, Poll}; use h2::client::{handshake, Handshake}; -use std::collections::HashMap; +// use std::collections::HashMap; +// use ahash::AHashMap as HashMap; +use hashbrown::HashMap; use http::uri::Authority; use indexmap::IndexSet; use slab::Slab; diff --git a/actix-http/src/extensions.rs b/actix-http/src/extensions.rs index 2bd0bf2f2..eb8dd7865 100644 --- a/actix-http/src/extensions.rs +++ b/actix-http/src/extensions.rs @@ -1,7 +1,9 @@ use std::any::{Any, TypeId}; use std::fmt; -use std::collections::HashMap; +// use std::collections::HashMap; +// use ahash::AHashMap as HashMap; +use hashbrown::HashMap; #[derive(Default)] /// A type map of request extensions. diff --git a/actix-http/src/header/map.rs b/actix-http/src/header/map.rs index 9d2a0081c..2648afbc2 100644 --- a/actix-http/src/header/map.rs +++ b/actix-http/src/header/map.rs @@ -1,6 +1,9 @@ use either::Either; -use std::collections::hash_map::{self, Entry}; -use std::collections::HashMap; +// use std::collections::hash_map::{self, Entry}; +// use std::collections::HashMap; +// use ahash::AHashMap as HashMap; +use hashbrown::hash_map::{self, Entry}; +use hashbrown::HashMap; use http::header::{HeaderName, HeaderValue}; use http::HttpTryFrom; diff --git a/actix-session/src/lib.rs b/actix-session/src/lib.rs index 6da9e5404..f7298fdc3 100644 --- a/actix-session/src/lib.rs +++ b/actix-session/src/lib.rs @@ -47,7 +47,8 @@ use std::rc::Rc; use actix_web::dev::{Extensions, Payload, ServiceRequest, ServiceResponse}; use actix_web::{Error, FromRequest, HttpMessage, HttpRequest}; -use std::collections::HashMap; +// use std::collections::HashMap; +use hashbrown::HashMap; use serde::de::DeserializeOwned; use serde::Serialize; use serde_json; diff --git a/src/rmap.rs b/src/rmap.rs index f9138b911..868901d52 100644 --- a/src/rmap.rs +++ b/src/rmap.rs @@ -2,7 +2,9 @@ use std::cell::RefCell; use std::rc::Rc; use actix_router::ResourceDef; -use std::collections::HashMap; +// use std::collections::HashMap; +// use hashbrown::HashMap; +use ahash::AHashMap as HashMap; use url::Url; use crate::error::UrlGenerationError;