From 80453e86737c9ddd2f73762e629eab7ee7b917bc Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 26 Oct 2026 20:55:06 +0000 Subject: [PATCH] refactor(psd): move the test counters module to counters.rs --- crates/psd/src/counters.rs | 19 +++++++++++++++++++ crates/psd/src/lib.rs | 22 +--------------------- 2 files changed, 20 insertions(+), 21 deletions(-) create mode 100644 crates/psd/src/counters.rs diff --git a/crates/psd/src/counters.rs b/crates/psd/src/counters.rs new file mode 100644 index 000000000..f5c59b02c --- /dev/null +++ b/crates/psd/src/counters.rs @@ -0,0 +1,19 @@ +use std::cell::Cell; +use std::thread::LocalKey; + +thread_local! { + /// Scratch rows allocated by the 32-bit ZIP un-predictor. + pub static SCRATCH: Cell = const { Cell::new(0) }; + /// `inside the mask rect` evaluations of the layer-mask loop. + pub static INSIDE: Cell = const { Cell::new(0) }; + /// `square_to_quad` solves. + pub static QUAD: Cell = const { Cell::new(0) }; +} + +pub fn bump(c: &'static LocalKey>) { + c.with(|c| c.set(c.get() + 1)); +} +/// Read and reset. +pub fn take(c: &'static LocalKey>) -> usize { + c.with(|c| c.replace(0)) +} diff --git a/crates/psd/src/lib.rs b/crates/psd/src/lib.rs index e515e9cb6..75bd4a4e7 100644 --- a/crates/psd/src/lib.rs +++ b/crates/psd/src/lib.rs @@ -1496,24 +1496,4 @@ mod tests; /// Test-only call counters (per thread), to prove what the optimised paths avoid doing. #[cfg(test)] -pub(crate) mod counters { - use std::cell::Cell; - use std::thread::LocalKey; - - thread_local! { - /// Scratch rows allocated by the 32-bit ZIP un-predictor. - pub static SCRATCH: Cell = const { Cell::new(0) }; - /// `inside the mask rect` evaluations of the layer-mask loop. - pub static INSIDE: Cell = const { Cell::new(0) }; - /// `square_to_quad` solves. - pub static QUAD: Cell = const { Cell::new(0) }; - } - - pub fn bump(c: &'static LocalKey>) { - c.with(|c| c.set(c.get() + 1)); - } - /// Read and reset. - pub fn take(c: &'static LocalKey>) -> usize { - c.with(|c| c.replace(0)) - } -} +pub(crate) mod counters;