From f21232a123fdad992d13ed4744585243dbc1c8ec Mon Sep 17 00:00:00 2001 From: Norbert Nemec Date: Sun, 1 Sep 2019 16:30:26 +0200 Subject: [PATCH] drop redundant copies from quaternion.rs --- src/quaternion.rs | 86 ----------------------------------------------- 1 file changed, 86 deletions(-) diff --git a/src/quaternion.rs b/src/quaternion.rs index a681d08..6957436 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -260,15 +260,6 @@ impl Quaternion { } } -#[cfg(not(feature = "simd"))] -impl InnerSpace for Quaternion { - #[inline] - fn dot(self, other: Quaternion) -> S { - self.s * other.s + self.v.dot(other.v) - } -} - -#[cfg(feature = "simd")] impl InnerSpace for Quaternion { #[inline] default_fn!( dot(self, other: Quaternion) -> S { @@ -311,14 +302,6 @@ where } } -#[cfg(not(feature = "simd"))] -impl_operator!( Neg for Quaternion { - fn neg(quat) -> Quaternion { - Quaternion::from_sv(-quat.s, -quat.v) - } -}); - -#[cfg(feature = "simd")] impl_operator!( Neg for Quaternion { fn neg(quat) -> Quaternion { Quaternion::from_sv(-quat.s, -quat.v) @@ -334,14 +317,6 @@ impl_operator_simd!{ } } -#[cfg(not(feature = "simd"))] -impl_operator!( Mul for Quaternion { - fn mul(lhs, rhs) -> Quaternion { - Quaternion::from_sv(lhs.s * rhs, lhs.v * rhs) - } -}); - -#[cfg(feature = "simd")] impl_operator!( Mul for Quaternion { fn mul(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s * rhs, lhs.v * rhs) @@ -357,12 +332,6 @@ impl_operator_simd!{@rs } } -#[cfg(not(feature = "simd"))] -impl_assignment_operator!( MulAssign for Quaternion { - fn mul_assign(&mut self, scalar) { self.s *= scalar; self.v *= scalar; } -}); - -#[cfg(feature = "simd")] impl_assignment_operator!( MulAssign for Quaternion { fn mul_assign(&mut self, scalar) { self.s *= scalar; self.v *= scalar; } }); @@ -376,14 +345,6 @@ impl MulAssign for Quaternion { } } -#[cfg(not(feature = "simd"))] -impl_operator!( Div for Quaternion { - fn div(lhs, rhs) -> Quaternion { - Quaternion::from_sv(lhs.s / rhs, lhs.v / rhs) - } -}); - -#[cfg(feature = "simd")] impl_operator!( Div for Quaternion { fn div(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s / rhs, lhs.v / rhs) @@ -399,12 +360,6 @@ impl_operator_simd!{@rs } } -#[cfg(not(feature = "simd"))] -impl_assignment_operator!( DivAssign for Quaternion { - fn div_assign(&mut self, scalar) { self.s /= scalar; self.v /= scalar; } -}); - -#[cfg(feature = "simd")] impl_assignment_operator!( DivAssign for Quaternion { fn div_assign(&mut self, scalar) { self.s /= scalar; self.v /= scalar; } }); @@ -437,14 +392,6 @@ impl_operator!( Mul > for Quaternion { }} }); -#[cfg(not(feature = "simd"))] -impl_operator!( Add > for Quaternion { - fn add(lhs, rhs) -> Quaternion { - Quaternion::from_sv(lhs.s + rhs.s, lhs.v + rhs.v) - } -}); - -#[cfg(feature = "simd")] impl_operator!( Add > for Quaternion { fn add(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s + rhs.s, lhs.v + rhs.v) @@ -460,12 +407,6 @@ impl_operator_simd!{ } } -#[cfg(not(feature = "simd"))] -impl_assignment_operator!( AddAssign > for Quaternion { - fn add_assign(&mut self, other) { self.s += other.s; self.v += other.v; } -}); - -#[cfg(feature = "simd")] impl_assignment_operator!( AddAssign > for Quaternion { fn add_assign(&mut self, other) { self.s += other.s; self.v += other.v; } }); @@ -480,14 +421,6 @@ impl AddAssign for Quaternion { } } -#[cfg(not(feature = "simd"))] -impl_operator!( Sub > for Quaternion { - fn sub(lhs, rhs) -> Quaternion { - Quaternion::from_sv(lhs.s - rhs.s, lhs.v - rhs.v) - } -}); - -#[cfg(feature = "simd")] impl_operator!( Sub > for Quaternion { fn sub(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s - rhs.s, lhs.v - rhs.v) @@ -503,12 +436,6 @@ impl_operator_simd!{ } } -#[cfg(not(feature = "simd"))] -impl_assignment_operator!( SubAssign > for Quaternion { - fn sub_assign(&mut self, other) { self.s -= other.s; self.v -= other.v; } -}); - -#[cfg(feature = "simd")] impl_assignment_operator!( SubAssign > for Quaternion { fn sub_assign(&mut self, other) { self.s -= other.s; self.v -= other.v; } }); @@ -523,19 +450,6 @@ impl SubAssign for Quaternion { } } -#[cfg(not(feature = "simd"))] -impl_operator!( Mul > for Quaternion { - fn mul(lhs, rhs) -> Quaternion { - Quaternion::new( - lhs.s * rhs.s - lhs.v.x * rhs.v.x - lhs.v.y * rhs.v.y - lhs.v.z * rhs.v.z, - lhs.s * rhs.v.x + lhs.v.x * rhs.s + lhs.v.y * rhs.v.z - lhs.v.z * rhs.v.y, - lhs.s * rhs.v.y + lhs.v.y * rhs.s + lhs.v.z * rhs.v.x - lhs.v.x * rhs.v.z, - lhs.s * rhs.v.z + lhs.v.z * rhs.s + lhs.v.x * rhs.v.y - lhs.v.y * rhs.v.x, - ) - } -}); - -#[cfg(feature = "simd")] impl_operator!( Mul > for Quaternion { fn mul(lhs, rhs) -> Quaternion { Quaternion::new(