From c1f0b16f205be4a4b83d23a3418d73c9e2de0a85 Mon Sep 17 00:00:00 2001 From: Shadow Cat Date: Sun, 21 Sep 2025 16:27:36 -0400 Subject: [PATCH] switch to fxhash --- Cargo.lock | 16 ++++++++++++++++ Cargo.toml | 1 + src/layout/painter.rs | 2 +- src/layout/text.rs | 2 +- src/layout/ui.rs | 4 ++-- src/util/mod.rs | 4 ++-- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e552aa4..e12080c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -256,6 +256,12 @@ dependencies = [ "syn", ] +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "byteorder-lite" version = "0.1.0" @@ -676,6 +682,15 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "gethostname" version = "0.4.3" @@ -2352,6 +2367,7 @@ version = "0.1.0" dependencies = [ "bytemuck", "cosmic-text", + "fxhash", "image", "pollster", "unicode-segmentation", diff --git a/Cargo.toml b/Cargo.toml index d28412b..254581d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,4 +13,5 @@ bytemuck = "1.23.1" image = "0.25.6" cosmic-text = "0.14.2" unicode-segmentation = "1.12.0" +fxhash = "0.2.1" diff --git a/src/layout/painter.rs b/src/layout/painter.rs index f0ee5d0..ca0ac07 100644 --- a/src/layout/painter.rs +++ b/src/layout/painter.rs @@ -55,7 +55,7 @@ impl<'a> PainterCtx<'a> { textures, text, screen_size, - drawing: HashSet::new(), + drawing: HashSet::default(), } } diff --git a/src/layout/text.rs b/src/layout/text.rs index f168d50..4a2603c 100644 --- a/src/layout/text.rs +++ b/src/layout/text.rs @@ -60,7 +60,7 @@ impl TextData { attrs: &TextAttrs, textures: &mut Textures, ) -> (TextureHandle, TextOffset) { - let mut pixels = HashMap::new(); + let mut pixels = HashMap::default(); let mut min_x = 0; let mut min_y = 0; let mut max_x = 0; diff --git a/src/layout/ui.rs b/src/layout/ui.rs index f40885f..dfea560 100644 --- a/src/layout/ui.rs +++ b/src/layout/ui.rs @@ -236,7 +236,7 @@ impl Widgets { pub fn new() -> Self { Self { ids: IdTracker::default(), - map: HashMap::new(), + map: HashMap::default(), } } @@ -298,7 +298,7 @@ impl Widgets { WidgetData { widget, label, - sized_children: HashSet::new(), + sized_children: HashSet::default(), borrowed: false, sensor: false, }, diff --git a/src/util/mod.rs b/src/util/mod.rs index 411a294..e5df3da 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -10,5 +10,5 @@ pub(crate) use id::*; pub(crate) use math::*; pub(crate) use refcount::*; -pub type HashMap = std::collections::HashMap; -pub type HashSet = std::collections::HashSet; +pub type HashMap = fxhash::FxHashMap; +pub type HashSet = fxhash::FxHashSet;