mirror of
https://github.com/Noratrieb/bool-toggle.git
synced 2026-01-14 12:25:01 +01:00
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.
This commit is contained in:
parent
b77a117724
commit
2d72dbbb78
1 changed files with 16 additions and 0 deletions
16
src/lib.rs
16
src/lib.rs
|
|
@ -21,6 +21,16 @@ impl TogglingIsALifestyle for bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(enterprise_license)]
|
||||||
|
impl<const N: usize> TogglingIsALifestyle for [bool; N] {
|
||||||
|
fn toggle(&mut self) {
|
||||||
|
// i am so fast
|
||||||
|
for b in self {
|
||||||
|
*b ^= true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[allow(clippy::bool_assert_comparison)]
|
#[allow(clippy::bool_assert_comparison)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
@ -51,4 +61,10 @@ mod enteprise_tests {
|
||||||
b.toggle();
|
b.toggle();
|
||||||
assert_eq!(b, true);
|
assert_eq!(b, true);
|
||||||
}
|
}
|
||||||
|
#[test]
|
||||||
|
fn enterprise_simd_toggle() {
|
||||||
|
let mut b = [false, true, false];
|
||||||
|
b.toggle();
|
||||||
|
assert_eq!(b, [true, false, true]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue