From b42d55b003aa69aa9471b82bb3c31eceeb8750d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 25 Feb 2023 22:37:54 +0100 Subject: [PATCH] Replace indexmap-amortized with plain (ahash) indexmap --- Cargo.lock | 33 ------------------- aquatic_common/Cargo.toml | 1 - aquatic_common/src/lib.rs | 3 -- aquatic_http/src/workers/swarm.rs | 9 ++--- .../src/workers/swarm/common.rs | 6 ++-- aquatic_udp/src/workers/swarm/storage.rs | 4 +-- aquatic_ws/src/workers/swarm.rs | 5 ++- 7 files changed, 11 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f4eb6c..e17c1d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,7 +81,6 @@ dependencies = [ "hex", "hwloc", "indexmap", - "indexmap-amortized", "libc", "log", "privdrop", @@ -417,12 +416,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "atone" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a8a5a5e2e3b1e128ec3783765c91c1f392172c1fffc90fd1b96a13bb18e0dd6" - [[package]] name = "atty" version = "0.2.14" @@ -1228,15 +1221,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "griddle" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e46a17d0c5d05b045e3814403914aeeb952aa9832f47b1d7ab123ab3d1660454" -dependencies = [ - "hashbrown 0.9.1", -] - [[package]] name = "half" version = "1.8.2" @@ -1253,12 +1237,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hashbrown" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" - [[package]] name = "hashbrown" version = "0.12.3" @@ -1457,17 +1435,6 @@ dependencies = [ "hashbrown 0.12.3", ] -[[package]] -name = "indexmap-amortized" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b5a05ffb45214e51fdd40c1f773ab57c74d2a7b41cfadc7ea443acf0359df1" -dependencies = [ - "atone", - "autocfg", - "griddle", -] - [[package]] name = "indicatif" version = "0.17.3" diff --git a/aquatic_common/Cargo.toml b/aquatic_common/Cargo.toml index d3cd52a..2de3408 100644 --- a/aquatic_common/Cargo.toml +++ b/aquatic_common/Cargo.toml @@ -26,7 +26,6 @@ git-testament = "0.2" hashbrown = "0.13" hex = "0.4" indexmap = "1" -indexmap-amortized = "1" libc = "0.2" log = "0.4" privdrop = "0.5" diff --git a/aquatic_common/src/lib.rs b/aquatic_common/src/lib.rs index 7d51312..96804ff 100644 --- a/aquatic_common/src/lib.rs +++ b/aquatic_common/src/lib.rs @@ -16,9 +16,6 @@ pub mod rustls_config; /// IndexMap using AHash hasher pub type IndexMap = indexmap::IndexMap; -/// Amortized IndexMap using AHash hasher -pub type AmortizedIndexMap = indexmap_amortized::IndexMap; - /// Peer, connection or similar valid until this instant #[derive(Debug, Clone, Copy)] pub struct ValidUntil(SecondsSinceServerStart); diff --git a/aquatic_http/src/workers/swarm.rs b/aquatic_http/src/workers/swarm.rs index 76893ad..ded87d8 100644 --- a/aquatic_http/src/workers/swarm.rs +++ b/aquatic_http/src/workers/swarm.rs @@ -16,9 +16,10 @@ use rand::SeedableRng; use smartstring::{LazyCompact, SmartString}; use aquatic_common::access_list::{create_access_list_cache, AccessListArcSwap, AccessListCache}; -use aquatic_common::{extract_response_peers, IndexMap, PanicSentinel}; -use aquatic_common::{AmortizedIndexMap, CanonicalSocketAddr}; -use aquatic_common::{SecondsSinceServerStart, ServerStartInstant, ValidUntil}; +use aquatic_common::{ + extract_response_peers, CanonicalSocketAddr, IndexMap, PanicSentinel, SecondsSinceServerStart, + ServerStartInstant, ValidUntil, +}; use aquatic_http_protocol::common::*; use aquatic_http_protocol::request::*; use aquatic_http_protocol::response::ResponsePeer; @@ -117,7 +118,7 @@ impl TorrentData { } } -pub type TorrentMap = AmortizedIndexMap>; +pub type TorrentMap = IndexMap>; #[derive(Default)] pub struct TorrentMaps { diff --git a/aquatic_http_private/src/workers/swarm/common.rs b/aquatic_http_private/src/workers/swarm/common.rs index 277da34..22ad497 100644 --- a/aquatic_http_private/src/workers/swarm/common.rs +++ b/aquatic_http_private/src/workers/swarm/common.rs @@ -1,8 +1,6 @@ use std::net::{Ipv4Addr, Ipv6Addr}; -use aquatic_common::{ - AmortizedIndexMap, IndexMap, SecondsSinceServerStart, ServerStartInstant, ValidUntil, -}; +use aquatic_common::{IndexMap, SecondsSinceServerStart, ServerStartInstant, ValidUntil}; use aquatic_http_protocol::common::{AnnounceEvent, InfoHash, PeerId}; use aquatic_http_protocol::response::ResponsePeer; @@ -76,7 +74,7 @@ impl Default for TorrentData { } } -pub type TorrentMap = AmortizedIndexMap>; +pub type TorrentMap = IndexMap>; #[derive(Default)] pub struct TorrentMaps { diff --git a/aquatic_udp/src/workers/swarm/storage.rs b/aquatic_udp/src/workers/swarm/storage.rs index 6db4ae3..e96416c 100644 --- a/aquatic_udp/src/workers/swarm/storage.rs +++ b/aquatic_udp/src/workers/swarm/storage.rs @@ -7,7 +7,7 @@ use aquatic_common::SecondsSinceServerStart; use aquatic_common::ServerStartInstant; use aquatic_common::{ access_list::{create_access_list_cache, AccessListArcSwap, AccessListCache, AccessListMode}, - extract_response_peers, AmortizedIndexMap, ValidUntil, + extract_response_peers, ValidUntil, }; use aquatic_udp_protocol::*; @@ -144,7 +144,7 @@ impl Default for TorrentData { } #[derive(Default)] -pub struct TorrentMap(pub AmortizedIndexMap>); +pub struct TorrentMap(pub IndexMap>); impl TorrentMap { /// Remove forbidden or inactive torrents, reclaim space and return number of remaining peers diff --git a/aquatic_ws/src/workers/swarm.rs b/aquatic_ws/src/workers/swarm.rs index 21806a3..d852044 100644 --- a/aquatic_ws/src/workers/swarm.rs +++ b/aquatic_ws/src/workers/swarm.rs @@ -13,8 +13,7 @@ use hashbrown::HashMap; use rand::{rngs::SmallRng, SeedableRng}; use aquatic_common::{ - extract_response_peers, AmortizedIndexMap, IndexMap, PanicSentinel, SecondsSinceServerStart, - ServerStartInstant, + extract_response_peers, IndexMap, PanicSentinel, SecondsSinceServerStart, ServerStartInstant, }; use aquatic_ws_protocol::*; @@ -87,7 +86,7 @@ impl TorrentData { } } -type TorrentMap = AmortizedIndexMap; +type TorrentMap = IndexMap; #[derive(Default)] struct TorrentMaps {