inline the primitive numeric operations

This commit is contained in:
Daniel Micay 2013-04-23 13:56:49 -04:00
parent 8cadcc47ee
commit a3e33cfb6e
4 changed files with 58 additions and 0 deletions

View File

@ -301,20 +301,28 @@ impl num::One for f32 {
#[cfg(notest)] #[cfg(notest)]
impl Add<f32,f32> for f32 { impl Add<f32,f32> for f32 {
#[inline(always)]
fn add(&self, other: &f32) -> f32 { *self + *other } fn add(&self, other: &f32) -> f32 { *self + *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Sub<f32,f32> for f32 { impl Sub<f32,f32> for f32 {
#[inline(always)]
fn sub(&self, other: &f32) -> f32 { *self - *other } fn sub(&self, other: &f32) -> f32 { *self - *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Mul<f32,f32> for f32 { impl Mul<f32,f32> for f32 {
#[inline(always)]
fn mul(&self, other: &f32) -> f32 { *self * *other } fn mul(&self, other: &f32) -> f32 { *self * *other }
} }
#[cfg(stage0,notest)] #[cfg(stage0,notest)]
impl Div<f32,f32> for f32 { impl Div<f32,f32> for f32 {
#[inline(always)]
fn div(&self, other: &f32) -> f32 { *self / *other } fn div(&self, other: &f32) -> f32 { *self / *other }
} }
#[cfg(stage1,notest)] #[cfg(stage1,notest)]
#[cfg(stage2,notest)] #[cfg(stage2,notest)]
#[cfg(stage3,notest)] #[cfg(stage3,notest)]
@ -322,10 +330,13 @@ impl Quot<f32,f32> for f32 {
#[inline(always)] #[inline(always)]
fn quot(&self, other: &f32) -> f32 { *self / *other } fn quot(&self, other: &f32) -> f32 { *self / *other }
} }
#[cfg(stage0,notest)] #[cfg(stage0,notest)]
impl Modulo<f32,f32> for f32 { impl Modulo<f32,f32> for f32 {
#[inline(always)]
fn modulo(&self, other: &f32) -> f32 { *self % *other } fn modulo(&self, other: &f32) -> f32 { *self % *other }
} }
#[cfg(stage1,notest)] #[cfg(stage1,notest)]
#[cfg(stage2,notest)] #[cfg(stage2,notest)]
#[cfg(stage3,notest)] #[cfg(stage3,notest)]
@ -333,8 +344,10 @@ impl Rem<f32,f32> for f32 {
#[inline(always)] #[inline(always)]
fn rem(&self, other: &f32) -> f32 { *self % *other } fn rem(&self, other: &f32) -> f32 { *self % *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Neg<f32> for f32 { impl Neg<f32> for f32 {
#[inline(always)]
fn neg(&self) -> f32 { -*self } fn neg(&self) -> f32 { -*self }
} }

View File

@ -455,18 +455,25 @@ impl num::Round for float {
#[cfg(notest)] #[cfg(notest)]
impl Add<float,float> for float { impl Add<float,float> for float {
#[inline(always)]
fn add(&self, other: &float) -> float { *self + *other } fn add(&self, other: &float) -> float { *self + *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Sub<float,float> for float { impl Sub<float,float> for float {
#[inline(always)]
fn sub(&self, other: &float) -> float { *self - *other } fn sub(&self, other: &float) -> float { *self - *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Mul<float,float> for float { impl Mul<float,float> for float {
#[inline(always)]
fn mul(&self, other: &float) -> float { *self * *other } fn mul(&self, other: &float) -> float { *self * *other }
} }
#[cfg(stage0,notest)] #[cfg(stage0,notest)]
impl Div<float,float> for float { impl Div<float,float> for float {
#[inline(always)]
fn div(&self, other: &float) -> float { *self / *other } fn div(&self, other: &float) -> float { *self / *other }
} }
#[cfg(stage1,notest)] #[cfg(stage1,notest)]
@ -478,6 +485,7 @@ impl Quot<float,float> for float {
} }
#[cfg(stage0,notest)] #[cfg(stage0,notest)]
impl Modulo<float,float> for float { impl Modulo<float,float> for float {
#[inline(always)]
fn modulo(&self, other: &float) -> float { *self % *other } fn modulo(&self, other: &float) -> float { *self % *other }
} }
#[cfg(stage1,notest)] #[cfg(stage1,notest)]
@ -489,6 +497,7 @@ impl Rem<float,float> for float {
} }
#[cfg(notest)] #[cfg(notest)]
impl Neg<float> for float { impl Neg<float> for float {
#[inline(always)]
fn neg(&self) -> float { -*self } fn neg(&self) -> float { -*self }
} }

View File

@ -175,20 +175,28 @@ impl num::One for T {
#[cfg(notest)] #[cfg(notest)]
impl Add<T,T> for T { impl Add<T,T> for T {
#[inline(always)]
fn add(&self, other: &T) -> T { *self + *other } fn add(&self, other: &T) -> T { *self + *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Sub<T,T> for T { impl Sub<T,T> for T {
#[inline(always)]
fn sub(&self, other: &T) -> T { *self - *other } fn sub(&self, other: &T) -> T { *self - *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Mul<T,T> for T { impl Mul<T,T> for T {
#[inline(always)]
fn mul(&self, other: &T) -> T { *self * *other } fn mul(&self, other: &T) -> T { *self * *other }
} }
#[cfg(stage0,notest)] #[cfg(stage0,notest)]
impl Div<T,T> for T { impl Div<T,T> for T {
#[inline(always)]
fn div(&self, other: &T) -> T { *self / *other } fn div(&self, other: &T) -> T { *self / *other }
} }
#[cfg(stage1,notest)] #[cfg(stage1,notest)]
#[cfg(stage2,notest)] #[cfg(stage2,notest)]
#[cfg(stage3,notest)] #[cfg(stage3,notest)]
@ -196,10 +204,13 @@ impl Quot<T,T> for T {
#[inline(always)] #[inline(always)]
fn quot(&self, other: &T) -> T { *self / *other } fn quot(&self, other: &T) -> T { *self / *other }
} }
#[cfg(stage0,notest)] #[cfg(stage0,notest)]
impl Modulo<T,T> for T { impl Modulo<T,T> for T {
#[inline(always)]
fn modulo(&self, other: &T) -> T { *self % *other } fn modulo(&self, other: &T) -> T { *self % *other }
} }
#[cfg(stage1,notest)] #[cfg(stage1,notest)]
#[cfg(stage2,notest)] #[cfg(stage2,notest)]
#[cfg(stage3,notest)] #[cfg(stage3,notest)]
@ -207,8 +218,10 @@ impl Rem<T,T> for T {
#[inline(always)] #[inline(always)]
fn rem(&self, other: &T) -> T { *self % *other } fn rem(&self, other: &T) -> T { *self % *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Neg<T> for T { impl Neg<T> for T {
#[inline(always)]
fn neg(&self) -> T { -*self } fn neg(&self) -> T { -*self }
} }
@ -217,26 +230,31 @@ impl BitOr<T,T> for T {
#[inline(always)] #[inline(always)]
fn bitor(&self, other: &T) -> T { *self | *other } fn bitor(&self, other: &T) -> T { *self | *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl BitAnd<T,T> for T { impl BitAnd<T,T> for T {
#[inline(always)] #[inline(always)]
fn bitand(&self, other: &T) -> T { *self & *other } fn bitand(&self, other: &T) -> T { *self & *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl BitXor<T,T> for T { impl BitXor<T,T> for T {
#[inline(always)] #[inline(always)]
fn bitxor(&self, other: &T) -> T { *self ^ *other } fn bitxor(&self, other: &T) -> T { *self ^ *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Shl<T,T> for T { impl Shl<T,T> for T {
#[inline(always)] #[inline(always)]
fn shl(&self, other: &T) -> T { *self << *other } fn shl(&self, other: &T) -> T { *self << *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Shr<T,T> for T { impl Shr<T,T> for T {
#[inline(always)] #[inline(always)]
fn shr(&self, other: &T) -> T { *self >> *other } fn shr(&self, other: &T) -> T { *self >> *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Not<T> for T { impl Not<T> for T {
#[inline(always)] #[inline(always)]

View File

@ -140,20 +140,28 @@ impl num::One for T {
#[cfg(notest)] #[cfg(notest)]
impl Add<T,T> for T { impl Add<T,T> for T {
#[inline(always)]
fn add(&self, other: &T) -> T { *self + *other } fn add(&self, other: &T) -> T { *self + *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Sub<T,T> for T { impl Sub<T,T> for T {
#[inline(always)]
fn sub(&self, other: &T) -> T { *self - *other } fn sub(&self, other: &T) -> T { *self - *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Mul<T,T> for T { impl Mul<T,T> for T {
#[inline(always)]
fn mul(&self, other: &T) -> T { *self * *other } fn mul(&self, other: &T) -> T { *self * *other }
} }
#[cfg(stage0,notest)] #[cfg(stage0,notest)]
impl Div<T,T> for T { impl Div<T,T> for T {
#[inline(always)]
fn div(&self, other: &T) -> T { *self / *other } fn div(&self, other: &T) -> T { *self / *other }
} }
#[cfg(stage1,notest)] #[cfg(stage1,notest)]
#[cfg(stage2,notest)] #[cfg(stage2,notest)]
#[cfg(stage3,notest)] #[cfg(stage3,notest)]
@ -161,10 +169,13 @@ impl Quot<T,T> for T {
#[inline(always)] #[inline(always)]
fn quot(&self, other: &T) -> T { *self / *other } fn quot(&self, other: &T) -> T { *self / *other }
} }
#[cfg(stage0,notest)] #[cfg(stage0,notest)]
impl Modulo<T,T> for T { impl Modulo<T,T> for T {
#[inline(always)]
fn modulo(&self, other: &T) -> T { *self % *other } fn modulo(&self, other: &T) -> T { *self % *other }
} }
#[cfg(stage1,notest)] #[cfg(stage1,notest)]
#[cfg(stage2,notest)] #[cfg(stage2,notest)]
#[cfg(stage3,notest)] #[cfg(stage3,notest)]
@ -172,8 +183,10 @@ impl Rem<T,T> for T {
#[inline(always)] #[inline(always)]
fn rem(&self, other: &T) -> T { *self % *other } fn rem(&self, other: &T) -> T { *self % *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Neg<T> for T { impl Neg<T> for T {
#[inline(always)]
fn neg(&self) -> T { -*self } fn neg(&self) -> T { -*self }
} }
@ -182,26 +195,31 @@ impl BitOr<T,T> for T {
#[inline(always)] #[inline(always)]
fn bitor(&self, other: &T) -> T { *self | *other } fn bitor(&self, other: &T) -> T { *self | *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl BitAnd<T,T> for T { impl BitAnd<T,T> for T {
#[inline(always)] #[inline(always)]
fn bitand(&self, other: &T) -> T { *self & *other } fn bitand(&self, other: &T) -> T { *self & *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl BitXor<T,T> for T { impl BitXor<T,T> for T {
#[inline(always)] #[inline(always)]
fn bitxor(&self, other: &T) -> T { *self ^ *other } fn bitxor(&self, other: &T) -> T { *self ^ *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Shl<T,T> for T { impl Shl<T,T> for T {
#[inline(always)] #[inline(always)]
fn shl(&self, other: &T) -> T { *self << *other } fn shl(&self, other: &T) -> T { *self << *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Shr<T,T> for T { impl Shr<T,T> for T {
#[inline(always)] #[inline(always)]
fn shr(&self, other: &T) -> T { *self >> *other } fn shr(&self, other: &T) -> T { *self >> *other }
} }
#[cfg(notest)] #[cfg(notest)]
impl Not<T> for T { impl Not<T> for T {
#[inline(always)] #[inline(always)]