diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ee6bfc9e..b931bdf1 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2002,6 +2002,7 @@ dependencies = [ "keyring", "mimalloc", "reqwest 0.12.28", + "rustc-hash", "rustls", "serde", "serde_json", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 88f4bba9..4636dde4 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -30,6 +30,7 @@ either = "1.15.0" futures = "0.3.31" mimalloc = "0.1" reqwest = { version = "0.12.15", features = ["json"] } +rustc-hash = "2.1.3" rustls = { version = "0.23.25", features = ["ring"] } serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" diff --git a/src-tauri/src/irc/message/tags.rs b/src-tauri/src/irc/message/tags.rs index 311804e4..fdb7ed14 100644 --- a/src-tauri/src/irc/message/tags.rs +++ b/src-tauri/src/irc/message/tags.rs @@ -1,8 +1,7 @@ -use std::collections::HashMap; -use std::collections::hash_map::RandomState; use std::fmt; use std::fmt::Write; +use rustc_hash::{FxBuildHasher, FxHashMap}; use serde::{Deserialize, Serialize}; use super::AsRawIrc; @@ -57,12 +56,12 @@ fn encode_tag_value(raw: &str) -> String { } #[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] -pub struct IrcTags(pub HashMap); +pub struct IrcTags(pub FxHashMap); impl IrcTags { /// Creates a new empty map of tags. pub fn new() -> IrcTags { - IrcTags(HashMap::new()) + IrcTags(FxHashMap::default()) } /// Panics if `source` is an empty string. @@ -72,7 +71,10 @@ impl IrcTags { } let tag_count = source.as_bytes().iter().filter(|&&b| b == b';').count() + 1; - let mut tags = IrcTags(HashMap::with_capacity(tag_count)); + let mut tags = IrcTags(FxHashMap::with_capacity_and_hasher( + tag_count, + FxBuildHasher, + )); for raw_tag in source.split(';') { let mut tag_split = raw_tag.splitn(2, '='); @@ -89,8 +91,8 @@ impl IrcTags { } } -impl From> for IrcTags { - fn from(map: HashMap) -> Self { +impl From> for IrcTags { + fn from(map: FxHashMap) -> Self { IrcTags(map) } } @@ -118,13 +120,13 @@ impl AsRawIrc for IrcTags { } } -impl PartialEq> for IrcTags { - fn eq(&self, other: &HashMap) -> bool { +impl PartialEq> for IrcTags { + fn eq(&self, other: &FxHashMap) -> bool { &self.0 == other } } -impl PartialEq for HashMap { +impl PartialEq for FxHashMap { fn eq(&self, other: &IrcTags) -> bool { self == &other.0 }