Skip to content

Commit

Permalink
Use AHashMap in place of most HashMaps
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethloeffler committed Oct 30, 2024
1 parent e909f45 commit 2ff2789
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions rbx_binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ rbx_dom_weak = { version = "2.9.0", path = "../rbx_dom_weak" }
rbx_reflection = { version = "4.7.0", path = "../rbx_reflection" }
rbx_reflection_database = { version = "0.2.12", path = "../rbx_reflection_database" }

ahash = "0.8.11"
log = "0.4.17"
lz4 = "1.23.3"
thiserror = "1.0.31"
Expand Down
8 changes: 2 additions & 6 deletions rbx_binary/src/deserializer/state.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use std::{
borrow::Cow,
collections::{HashMap, HashSet, VecDeque},
convert::TryInto,
io::Read,
};
use std::{borrow::Cow, collections::VecDeque, convert::TryInto, io::Read};

use ahash::{HashMap, HashMapExt, HashSet, HashSetExt};
use rbx_dom_weak::{
types::{
Attributes, Axes, BinaryString, BrickColor, CFrame, Color3, Color3uint8, ColorSequence,
Expand Down
3 changes: 2 additions & 1 deletion rbx_binary/src/serializer/state.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::{
borrow::{Borrow, Cow},
collections::{btree_map, BTreeMap, BTreeSet, HashMap, HashSet},
collections::{btree_map, BTreeMap, BTreeSet},
convert::TryInto,
io::Write,
};

use ahash::{HashMap, HashMapExt, HashSet, HashSetExt};
use rbx_dom_weak::{
types::{
Attributes, Axes, BinaryString, BrickColor, CFrame, Color3, Color3uint8, ColorSequence,
Expand Down
1 change: 1 addition & 0 deletions rbx_dom_weak/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ edition = "2018"
rbx_types = { version = "1.10.0", path = "../rbx_types", features = ["serde"] }
ustr = { version = "1.1.0", features = ["serde"] }

ahash = "0.8.11"
serde = "1.0.137"

[dev-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion rbx_dom_weak/src/dom.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::collections::{HashMap, HashSet, VecDeque};
use std::collections::VecDeque;

use ahash::{HashMap, HashMapExt, HashSet, HashSetExt};
use rbx_types::{Ref, UniqueId, Variant};
use ustr::ustr;

Expand Down
1 change: 1 addition & 0 deletions rbx_reflection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ edition = "2018"
[dependencies]
rbx_types = { version = "1.10.0", path = "../rbx_types", features = ["serde"] }

ahash = "0.8.11"
serde = { version = "1.0.137", features = ["derive"] }
thiserror = "1.0.31"
6 changes: 2 additions & 4 deletions rbx_reflection/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
// for most cases.
#![allow(clippy::new_without_default)]

use std::{
borrow::Cow,
collections::{HashMap, HashSet},
};
use std::borrow::Cow;

use ahash::{HashMap, HashMapExt, HashSet, HashSetExt};
use rbx_types::{Variant, VariantType};
use serde::{Deserialize, Serialize};

Expand Down
3 changes: 2 additions & 1 deletion rbx_reflection/src/serde_util.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::{
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
collections::{BTreeMap, BTreeSet},
hash::Hash,
};

use ahash::{HashMap, HashSet};
use serde::{Serialize, Serializer};

pub(crate) fn ordered_map<S, K, V>(value: &HashMap<K, V>, serializer: S) -> Result<S::Ok, S::Error>
Expand Down
1 change: 1 addition & 0 deletions rbx_reflector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rbx_reflection = { path = "../rbx_reflection" }
rbx_types = { path = "../rbx_types", features = ["serde"] }
rbx_xml = { path = "../rbx_xml" }

ahash = "0.8.11"
anyhow = "1.0.57"
clap = { version = "4.1.4", features = ["derive"] }
env_logger = "0.10.0"
Expand Down
2 changes: 1 addition & 1 deletion rbx_reflector/src/cli/generate.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::{
borrow::Cow,
collections::{HashMap, HashSet},
fs::{self, File},
io::{BufWriter, Write},
path::PathBuf,
};

use ahash::{HashMap, HashMapExt, HashSet, HashSetExt};
use anyhow::{bail, Context};
use clap::Parser;
use rbx_reflection::{
Expand Down

0 comments on commit 2ff2789

Please sign in to comment.