Add #[inline(always)] to each operator method
This commit is contained in:
parent
d2a81b95c3
commit
939a97f5cb
5 changed files with 50 additions and 0 deletions
|
|
@ -288,26 +288,32 @@ impl num::One for f32 {
|
|||
|
||||
#[cfg(notest)]
|
||||
impl ops::Add<f32,f32> for f32 {
|
||||
#[inline(always)]
|
||||
fn add(&self, other: &f32) -> f32 { *self + *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Sub<f32,f32> for f32 {
|
||||
#[inline(always)]
|
||||
fn sub(&self, other: &f32) -> f32 { *self - *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Mul<f32,f32> for f32 {
|
||||
#[inline(always)]
|
||||
fn mul(&self, other: &f32) -> f32 { *self * *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Div<f32,f32> for f32 {
|
||||
#[inline(always)]
|
||||
fn div(&self, other: &f32) -> f32 { *self / *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Modulo<f32,f32> for f32 {
|
||||
#[inline(always)]
|
||||
fn modulo(&self, other: &f32) -> f32 { *self % *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Neg<f32> for f32 {
|
||||
#[inline(always)]
|
||||
fn neg(&self) -> f32 { -*self }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -310,26 +310,32 @@ impl num::One for f64 {
|
|||
|
||||
#[cfg(notest)]
|
||||
impl ops::Add<f64,f64> for f64 {
|
||||
#[inline(always)]
|
||||
fn add(&self, other: &f64) -> f64 { *self + *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Sub<f64,f64> for f64 {
|
||||
#[inline(always)]
|
||||
fn sub(&self, other: &f64) -> f64 { *self - *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Mul<f64,f64> for f64 {
|
||||
#[inline(always)]
|
||||
fn mul(&self, other: &f64) -> f64 { *self * *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Div<f64,f64> for f64 {
|
||||
#[inline(always)]
|
||||
fn div(&self, other: &f64) -> f64 { *self / *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Modulo<f64,f64> for f64 {
|
||||
#[inline(always)]
|
||||
fn modulo(&self, other: &f64) -> f64 { *self % *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Neg<f64> for f64 {
|
||||
#[inline(always)]
|
||||
fn neg(&self) -> f64 { -*self }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -387,15 +387,21 @@ pub fn tan(x: float) -> float {
|
|||
|
||||
#[cfg(notest)]
|
||||
impl Eq for float {
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: &float) -> bool { (*self) == (*other) }
|
||||
#[inline(always)]
|
||||
fn ne(&self, other: &float) -> bool { (*self) != (*other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl Ord for float {
|
||||
#[inline(always)]
|
||||
fn lt(&self, other: &float) -> bool { (*self) < (*other) }
|
||||
#[inline(always)]
|
||||
fn le(&self, other: &float) -> bool { (*self) <= (*other) }
|
||||
#[inline(always)]
|
||||
fn ge(&self, other: &float) -> bool { (*self) >= (*other) }
|
||||
#[inline(always)]
|
||||
fn gt(&self, other: &float) -> bool { (*self) > (*other) }
|
||||
}
|
||||
|
||||
|
|
@ -444,26 +450,32 @@ impl num::Round for float {
|
|||
|
||||
#[cfg(notest)]
|
||||
impl ops::Add<float,float> for float {
|
||||
#[inline(always)]
|
||||
fn add(&self, other: &float) -> float { *self + *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Sub<float,float> for float {
|
||||
#[inline(always)]
|
||||
fn sub(&self, other: &float) -> float { *self - *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Mul<float,float> for float {
|
||||
#[inline(always)]
|
||||
fn mul(&self, other: &float) -> float { *self * *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Div<float,float> for float {
|
||||
#[inline(always)]
|
||||
fn div(&self, other: &float) -> float { *self / *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Modulo<float,float> for float {
|
||||
#[inline(always)]
|
||||
fn modulo(&self, other: &float) -> float { *self % *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Neg<float> for float {
|
||||
#[inline(always)]
|
||||
fn neg(&self) -> float { -*self }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,50 +177,63 @@ impl num::One for T {
|
|||
|
||||
#[cfg(notest)]
|
||||
impl ops::Add<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn add(&self, other: &T) -> T { *self + *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Sub<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn sub(&self, other: &T) -> T { *self - *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Mul<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn mul(&self, other: &T) -> T { *self * *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Div<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn div(&self, other: &T) -> T { *self / *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Modulo<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn modulo(&self, other: &T) -> T { *self % *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Neg<T> for T {
|
||||
#[inline(always)]
|
||||
fn neg(&self) -> T { -*self }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl ops::BitOr<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn bitor(&self, other: &T) -> T { *self | *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::BitAnd<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn bitand(&self, other: &T) -> T { *self & *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::BitXor<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn bitxor(&self, other: &T) -> T { *self ^ *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Shl<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn shl(&self, other: &T) -> T { *self << *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Shr<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn shr(&self, other: &T) -> T { *self >> *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Not<T> for T {
|
||||
#[inline(always)]
|
||||
fn not(&self) -> T { !*self }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,50 +142,63 @@ impl num::One for T {
|
|||
|
||||
#[cfg(notest)]
|
||||
impl ops::Add<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn add(&self, other: &T) -> T { *self + *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Sub<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn sub(&self, other: &T) -> T { *self - *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Mul<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn mul(&self, other: &T) -> T { *self * *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Div<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn div(&self, other: &T) -> T { *self / *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Modulo<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn modulo(&self, other: &T) -> T { *self % *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Neg<T> for T {
|
||||
#[inline(always)]
|
||||
fn neg(&self) -> T { -*self }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl ops::BitOr<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn bitor(&self, other: &T) -> T { *self | *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::BitAnd<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn bitand(&self, other: &T) -> T { *self & *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::BitXor<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn bitxor(&self, other: &T) -> T { *self ^ *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Shl<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn shl(&self, other: &T) -> T { *self << *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Shr<T,T> for T {
|
||||
#[inline(always)]
|
||||
fn shr(&self, other: &T) -> T { *self >> *other }
|
||||
}
|
||||
#[cfg(notest)]
|
||||
impl ops::Not<T> for T {
|
||||
#[inline(always)]
|
||||
fn not(&self) -> T { !*self }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue