Skip to content

inline the primitive numeric operations #6034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,40 +301,53 @@ impl num::One for f32 {

#[cfg(notest)]
impl Add<f32,f32> for f32 {
#[inline(always)]
fn add(&self, other: &f32) -> f32 { *self + *other }
}

#[cfg(notest)]
impl Sub<f32,f32> for f32 {
#[inline(always)]
fn sub(&self, other: &f32) -> f32 { *self - *other }
}

#[cfg(notest)]
impl Mul<f32,f32> for f32 {
#[inline(always)]
fn mul(&self, other: &f32) -> f32 { *self * *other }
}

#[cfg(stage0,notest)]
impl Div<f32,f32> for f32 {
#[inline(always)]
fn div(&self, other: &f32) -> f32 { *self / *other }
}

#[cfg(stage1,notest)]
#[cfg(stage2,notest)]
#[cfg(stage3,notest)]
impl Quot<f32,f32> for f32 {
#[inline(always)]
fn quot(&self, other: &f32) -> f32 { *self / *other }
}

#[cfg(stage0,notest)]
impl Modulo<f32,f32> for f32 {
#[inline(always)]
fn modulo(&self, other: &f32) -> f32 { *self % *other }
}

#[cfg(stage1,notest)]
#[cfg(stage2,notest)]
#[cfg(stage3,notest)]
impl Rem<f32,f32> for f32 {
#[inline(always)]
fn rem(&self, other: &f32) -> f32 { *self % *other }
}

#[cfg(notest)]
impl Neg<f32> for f32 {
#[inline(always)]
fn neg(&self) -> f32 { -*self }
}

Expand Down
9 changes: 9 additions & 0 deletions src/libcore/num/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,18 +455,25 @@ impl num::Round for float {

#[cfg(notest)]
impl Add<float,float> for float {
#[inline(always)]
fn add(&self, other: &float) -> float { *self + *other }
}

#[cfg(notest)]
impl Sub<float,float> for float {
#[inline(always)]
fn sub(&self, other: &float) -> float { *self - *other }
}

#[cfg(notest)]
impl Mul<float,float> for float {
#[inline(always)]
fn mul(&self, other: &float) -> float { *self * *other }
}

#[cfg(stage0,notest)]
impl Div<float,float> for float {
#[inline(always)]
fn div(&self, other: &float) -> float { *self / *other }
}
#[cfg(stage1,notest)]
Expand All @@ -478,6 +485,7 @@ impl Quot<float,float> for float {
}
#[cfg(stage0,notest)]
impl Modulo<float,float> for float {
#[inline(always)]
fn modulo(&self, other: &float) -> float { *self % *other }
}
#[cfg(stage1,notest)]
Expand All @@ -489,6 +497,7 @@ impl Rem<float,float> for float {
}
#[cfg(notest)]
impl Neg<float> for float {
#[inline(always)]
fn neg(&self) -> float { -*self }
}

Expand Down
18 changes: 18 additions & 0 deletions src/libcore/num/int-template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,40 +175,53 @@ impl num::One for T {

#[cfg(notest)]
impl Add<T,T> for T {
#[inline(always)]
fn add(&self, other: &T) -> T { *self + *other }
}

#[cfg(notest)]
impl Sub<T,T> for T {
#[inline(always)]
fn sub(&self, other: &T) -> T { *self - *other }
}

#[cfg(notest)]
impl Mul<T,T> for T {
#[inline(always)]
fn mul(&self, other: &T) -> T { *self * *other }
}

#[cfg(stage0,notest)]
impl Div<T,T> for T {
#[inline(always)]
fn div(&self, other: &T) -> T { *self / *other }
}

#[cfg(stage1,notest)]
#[cfg(stage2,notest)]
#[cfg(stage3,notest)]
impl Quot<T,T> for T {
#[inline(always)]
fn quot(&self, other: &T) -> T { *self / *other }
}

#[cfg(stage0,notest)]
impl Modulo<T,T> for T {
#[inline(always)]
fn modulo(&self, other: &T) -> T { *self % *other }
}

#[cfg(stage1,notest)]
#[cfg(stage2,notest)]
#[cfg(stage3,notest)]
impl Rem<T,T> for T {
#[inline(always)]
fn rem(&self, other: &T) -> T { *self % *other }
}

#[cfg(notest)]
impl Neg<T> for T {
#[inline(always)]
fn neg(&self) -> T { -*self }
}

Expand All @@ -217,26 +230,31 @@ impl BitOr<T,T> for T {
#[inline(always)]
fn bitor(&self, other: &T) -> T { *self | *other }
}

#[cfg(notest)]
impl BitAnd<T,T> for T {
#[inline(always)]
fn bitand(&self, other: &T) -> T { *self & *other }
}

#[cfg(notest)]
impl BitXor<T,T> for T {
#[inline(always)]
fn bitxor(&self, other: &T) -> T { *self ^ *other }
}

#[cfg(notest)]
impl Shl<T,T> for T {
#[inline(always)]
fn shl(&self, other: &T) -> T { *self << *other }
}

#[cfg(notest)]
impl Shr<T,T> for T {
#[inline(always)]
fn shr(&self, other: &T) -> T { *self >> *other }
}

#[cfg(notest)]
impl Not<T> for T {
#[inline(always)]
Expand Down
18 changes: 18 additions & 0 deletions src/libcore/num/uint-template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,53 @@ impl num::One for T {

#[cfg(notest)]
impl Add<T,T> for T {
#[inline(always)]
fn add(&self, other: &T) -> T { *self + *other }
}

#[cfg(notest)]
impl Sub<T,T> for T {
#[inline(always)]
fn sub(&self, other: &T) -> T { *self - *other }
}

#[cfg(notest)]
impl Mul<T,T> for T {
#[inline(always)]
fn mul(&self, other: &T) -> T { *self * *other }
}

#[cfg(stage0,notest)]
impl Div<T,T> for T {
#[inline(always)]
fn div(&self, other: &T) -> T { *self / *other }
}

#[cfg(stage1,notest)]
#[cfg(stage2,notest)]
#[cfg(stage3,notest)]
impl Quot<T,T> for T {
#[inline(always)]
fn quot(&self, other: &T) -> T { *self / *other }
}

#[cfg(stage0,notest)]
impl Modulo<T,T> for T {
#[inline(always)]
fn modulo(&self, other: &T) -> T { *self % *other }
}

#[cfg(stage1,notest)]
#[cfg(stage2,notest)]
#[cfg(stage3,notest)]
impl Rem<T,T> for T {
#[inline(always)]
fn rem(&self, other: &T) -> T { *self % *other }
}

#[cfg(notest)]
impl Neg<T> for T {
#[inline(always)]
fn neg(&self) -> T { -*self }
}

Expand All @@ -182,26 +195,31 @@ impl BitOr<T,T> for T {
#[inline(always)]
fn bitor(&self, other: &T) -> T { *self | *other }
}

#[cfg(notest)]
impl BitAnd<T,T> for T {
#[inline(always)]
fn bitand(&self, other: &T) -> T { *self & *other }
}

#[cfg(notest)]
impl BitXor<T,T> for T {
#[inline(always)]
fn bitxor(&self, other: &T) -> T { *self ^ *other }
}

#[cfg(notest)]
impl Shl<T,T> for T {
#[inline(always)]
fn shl(&self, other: &T) -> T { *self << *other }
}

#[cfg(notest)]
impl Shr<T,T> for T {
#[inline(always)]
fn shr(&self, other: &T) -> T { *self >> *other }
}

#[cfg(notest)]
impl Not<T> for T {
#[inline(always)]
Expand Down