From 2d72dbbb781fcd69a83c8063b115c80a02989828 Mon Sep 17 00:00:00 2001 From: Wanja Hentze Date: Thu, 8 Feb 2024 20:03:49 +0100 Subject: [PATCH] add portable SIMD toggling support for large-scale enterprise deployments (#1) As global usage of compute resources keeps climbing, driven by machine learning and virtual reality, we have to find ever new ways to make our programs more efficient. To this end, I have added a hyperoptimized SIMD version of the very important bool toggling functionality. This introduces const generics to the crate, so MSRV will have to be bumped to 1.2000.0 in the upcoming release. --- src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index afd5510..ece3177 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,16 @@ impl TogglingIsALifestyle for bool { } } +#[cfg(enterprise_license)] +impl TogglingIsALifestyle for [bool; N] { + fn toggle(&mut self) { + // i am so fast + for b in self { + *b ^= true; + } + } +} + #[cfg(test)] #[allow(clippy::bool_assert_comparison)] mod tests { @@ -51,4 +61,10 @@ mod enteprise_tests { b.toggle(); assert_eq!(b, true); } + #[test] + fn enterprise_simd_toggle() { + let mut b = [false, true, false]; + b.toggle(); + assert_eq!(b, [true, false, true]); + } }