From 0eec25d14b6210e74915c7950f75750a6c319d7b Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 18 Oct 2026 00:45:49 +0200 Subject: [PATCH] Sculk: Fx hashing for the per-mob step and damage maps entity_motion_events looked up each moving mob in a SipHash map every tick. The keys are mob ids the server gives out, so the fast hasher is safe there. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/sculk.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/game/sculk.rs b/crates/horizon-client/src/game/sculk.rs index 04e02d360..72a91d7da 100644 --- a/crates/horizon-client/src/game/sculk.rs +++ b/crates/horizon-client/src/game/sculk.rs @@ -6,13 +6,14 @@ use super::{Game, Result}; use horizon_client::{ containers::BlockEntity, + fast_hash::{FxHashMap, FxHashSet}, mobs::{Mob, Species, Who, warden}, particles::{ParticleOptions, ParticleType}, sculk::{self, Context, Info, SculkEntity, SculkKind, WardenSpawnTracker}, }; use horizon_core::{geometry::Direction, position::BlockPos, random::RandomSource}; use horizon_world::registry::BlockStateId; -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; use winit::keyboard::KeyCode; pub const HELP: &[&str] = &[ @@ -70,8 +71,9 @@ pub(super) struct SculkState { /// The sculk block entities in the order they were added. index: Index, pub known: HashSet<(i32, i32)>, - steps: HashMap, - damaged: HashMap, + // Keyed by mob ids the server gives out: the fast hasher is safe. + steps: FxHashMap, + damaged: FxHashMap, last_health: Option, /// The darkness effect's blend factor, previous and current tick. darkness: (f32, f32), @@ -1528,7 +1530,7 @@ impl Game<'_> { } } } - let alive: HashSet = self.mobs.iter().map(|m| m.id).collect(); + let alive: FxHashSet = self.mobs.iter().map(|m| m.id).collect(); self.sculk.damaged.retain(|id, _| alive.contains(id)); self.sculk.steps.retain(|who, _| match who { Who::Player => true,