From 3a7031961ca6a8350a1e18f13566f6ff39027de9 Mon Sep 17 00:00:00 2001 From: Katherine Kiefer Date: Sat, 22 Jul 2023 23:17:39 +1000 Subject: [PATCH] use hashbrown --- Cargo.lock | 11 +++++++++++ Cargo.toml | 3 ++- src/gas/types.rs | 4 +++- src/reaction.rs | 2 +- src/reaction/hooks.rs | 2 +- src/turfs/katmos.rs | 4 +++- 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0195105c..fc113cc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,6 +34,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "atomic_float" version = "0.1.0" @@ -92,6 +98,7 @@ dependencies = [ "float-ord", "flume", "fxhash", + "hashbrown 0.14.0", "indexmap 2.0.0", "itertools", "lazy_static", @@ -412,6 +419,10 @@ name = "hashbrown" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +dependencies = [ + "ahash 0.8.3", + "allocator-api2", +] [[package]] name = "hermit-abi" diff --git a/Cargo.toml b/Cargo.toml index 455ccd26..1a2d7a8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["auxcleanup_gas_deletion", "turf_processing", "katmos"] +default = ["auxcleanup_gas_deletion", "turf_processing"] auxcleanup_gas_deletion = ["auxcleanup"] zas_hooks = [] turf_processing = [] @@ -44,6 +44,7 @@ ahash = "0.8.3" lazy_static = "1.4.0" indexmap = { version = "2.0.0", features = ["rayon"] } dashmap = { version = "5.5.0", features = ["rayon"] } +hashbrown = "0.14.0" atomic_float = "0.1.0" petgraph = "0.6.3" bitflags = "2.3.3" diff --git a/src/gas/types.rs b/src/gas/types.rs index 09f2f9d8..45255893 100644 --- a/src/gas/types.rs +++ b/src/gas/types.rs @@ -13,10 +13,12 @@ use dashmap::DashMap; use std::{ cell::RefCell, - collections::{BTreeMap, HashMap}, + collections::BTreeMap, sync::atomic::{AtomicUsize, Ordering}, }; +use hashbrown::HashMap; + static TOTAL_NUM_GASES: AtomicUsize = AtomicUsize::new(0); static REACTION_INFO: RwLock>> = const_rwlock(None); diff --git a/src/reaction.rs b/src/reaction.rs index f6b8860d..9efa9257 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -25,7 +25,7 @@ pub struct Reaction { } use fxhash::FxBuildHasher; -use std::collections::HashMap; +use hashbrown::HashMap; enum ReactionSide { ByondSide(Value), diff --git a/src/reaction/hooks.rs b/src/reaction/hooks.rs index a9be24eb..05185e56 100644 --- a/src/reaction/hooks.rs +++ b/src/reaction/hooks.rs @@ -338,7 +338,7 @@ fn fusion(byond_air: &Value, holder: &Value) -> DMResult { #[cfg(feature = "generic_fire_hook")] fn generic_fire(byond_air: &Value, holder: &Value) -> DMResult { use fxhash::FxBuildHasher; - use std::collections::HashMap; + use hashbrown::HashMap; let mut burn_results: HashMap = HashMap::with_capacity_and_hasher( super::total_num_gases() as usize, FxBuildHasher::default(), diff --git a/src/turfs/katmos.rs b/src/turfs/katmos.rs index 0195651f..8fc2c3d7 100644 --- a/src/turfs/katmos.rs +++ b/src/turfs/katmos.rs @@ -15,11 +15,13 @@ use coarsetime::{Duration, Instant}; use std::{ cell::Cell, { - collections::{BTreeSet, HashMap, HashSet}, + collections::BTreeSet, sync::atomic::{AtomicUsize, Ordering}, }, }; +use hashbrown::{HashMap, HashSet}; + use parking_lot::{const_mutex, Mutex}; static EQUALIZE_CHANNEL: Mutex>> = const_mutex(None);