From 12fb94204f4eb8923d4830c007923539d1a6b8f5 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 27 Jan 2019 11:40:26 -0800 Subject: [PATCH] use hashbrown instead of std HashMap --- Cargo.toml | 6 ++---- src/client/pool.rs | 5 +++-- src/extensions.rs | 31 ++----------------------------- test-server/Cargo.toml | 10 ---------- 4 files changed, 7 insertions(+), 45 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 426712201..b3adfa823 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,10 +44,6 @@ actix-codec = "0.1.0" actix-connector = { git = "https://github.com/actix/actix-net.git" } actix-utils = { git = "https://github.com/actix/actix-net.git" } -# actix-codec = { path="../actix-net/actix-codec/" } -# actix-connector = { path="../actix-net/actix-connector/" } -# actix-utils = { path="../actix-net/actix-utils/" } - base64 = "0.10" backtrace = "0.3" bitflags = "1.0" @@ -57,6 +53,8 @@ cookie = { version="0.11", features=["percent-encode"] } derive_more = "0.13" encoding = "0.2" futures = "0.1" +hashbrown = "0.1.8" +h2 = "0.1.16" http = "0.1.8" httparse = "1.3" indexmap = "1.0" diff --git a/src/client/pool.rs b/src/client/pool.rs index 11828dcb8..b577587d8 100644 --- a/src/client/pool.rs +++ b/src/client/pool.rs @@ -1,5 +1,5 @@ use std::cell::RefCell; -use std::collections::{HashMap, VecDeque}; +use std::collections::VecDeque; use std::io; use std::rc::Rc; use std::time::{Duration, Instant}; @@ -7,9 +7,10 @@ use std::time::{Duration, Instant}; use actix_codec::{AsyncRead, AsyncWrite}; use actix_service::Service; use futures::future::{ok, Either, FutureResult}; -use futures::sync::oneshot; use futures::task::AtomicTask; +use futures::unsync::oneshot; use futures::{Async, Future, Poll}; +use hashbrown::HashMap; use http::uri::Authority; use indexmap::IndexSet; use slab::Slab; diff --git a/src/extensions.rs b/src/extensions.rs index 430b87bda..7bb965c96 100644 --- a/src/extensions.rs +++ b/src/extensions.rs @@ -1,40 +1,13 @@ use std::any::{Any, TypeId}; -use std::collections::HashMap; use std::fmt; use std::hash::{BuildHasherDefault, Hasher}; -struct IdHasher { - id: u64, -} - -impl Default for IdHasher { - fn default() -> IdHasher { - IdHasher { id: 0 } - } -} - -impl Hasher for IdHasher { - fn write(&mut self, bytes: &[u8]) { - for &x in bytes { - self.id.wrapping_add(u64::from(x)); - } - } - - fn write_u64(&mut self, u: u64) { - self.id = u; - } - - fn finish(&self) -> u64 { - self.id - } -} - -type AnyMap = HashMap, BuildHasherDefault>; +use hashbrown::HashMap; #[derive(Default)] /// A type map of request extensions. pub struct Extensions { - map: AnyMap, + map: HashMap>, } impl Extensions { diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index 5cede2dc2..851b3efe4 100644 --- a/test-server/Cargo.toml +++ b/test-server/Cargo.toml @@ -28,9 +28,6 @@ default = ["session"] # sessions feature, session require "ring" crate and c compiler session = ["cookie/secure"] -# openssl -ssl = ["openssl", "actix-http/ssl"] - [dependencies] actix-codec = "0.1" actix-service = "0.1.6" @@ -39,10 +36,6 @@ actix-server = "0.1.0" actix-http = { path=".." } actix-utils = { git = "https://github.com/actix/actix-net.git" } -# actix-codec = { path="../actix-net/actix-codec/" } -# actix-rt = { path="../actix-net/actix-rt/" } -# actix-server = { path="../actix-net/actix-server/" } - base64 = "0.10" bytes = "0.4" cookie = { version="0.11", features=["percent-encode"] } @@ -59,6 +52,3 @@ serde_urlencoded = "0.5.3" time = "0.1" tokio-tcp = "0.1" tokio-timer = "0.2" - -# openssl -openssl = { version="0.10", optional = true }