From 80930ddd351ef19ad13d75c121b6a0ed1e5ad8bb Mon Sep 17 00:00:00 2001 From: Xevion Date: Fri, 15 Aug 2025 18:40:24 -0500 Subject: [PATCH] fix: use const MAX_SYSTEMS to ensure micromap maps are aligned in size --- src/systems/profiling.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/systems/profiling.rs b/src/systems/profiling.rs index 730da86..b635aea 100644 --- a/src/systems/profiling.rs +++ b/src/systems/profiling.rs @@ -6,6 +6,9 @@ use parking_lot::{Mutex, RwLock}; use std::time::Duration; use thousands::Separable; +/// The maximum number of systems that can be profiled. Must not be exceeded, or it will panic. +const MAX_SYSTEMS: usize = 11; +/// The number of durations to keep in the circular buffer. const TIMING_WINDOW_SIZE: usize = 30; #[derive(Resource, Default, Debug)] @@ -17,7 +20,7 @@ pub struct SystemTimings { /// /// Also, we use a micromap::Map as the number of systems is generally quite small. /// Just make sure to set the capacity appropriately, or it will panic. - pub timings: RwLock>, 10>>, + pub timings: RwLock>, MAX_SYSTEMS>>, } impl SystemTimings { @@ -43,7 +46,7 @@ impl SystemTimings { }); } - pub fn get_stats(&self) -> Map<&'static str, (Duration, Duration), 10> { + pub fn get_stats(&self) -> Map<&'static str, (Duration, Duration), MAX_SYSTEMS> { let timings = self.timings.read(); let mut stats = Map::new();