diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2013-06-18 14:45:18 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2013-06-18 14:48:48 -0700 |
| commit | d904c72af830bd4bec773ce35897703dff2ee3b1 (patch) | |
| tree | c9253d1282f12af3aac7e854cd1115cd2eede863 /src/libstd/num | |
| parent | 303d7bfc87ca370354ac4264cc23a80cbcd8a792 (diff) | |
| download | rust-d904c72af830bd4bec773ce35897703dff2ee3b1.tar.gz rust-d904c72af830bd4bec773ce35897703dff2ee3b1.zip | |
replace #[inline(always)] with #[inline]. r=burningtree.
Diffstat (limited to 'src/libstd/num')
| -rw-r--r-- | src/libstd/num/f32.rs | 258 | ||||
| -rw-r--r-- | src/libstd/num/f64.rs | 264 | ||||
| -rw-r--r-- | src/libstd/num/float.rs | 258 | ||||
| -rw-r--r-- | src/libstd/num/i16.rs | 6 | ||||
| -rw-r--r-- | src/libstd/num/i32.rs | 6 | ||||
| -rw-r--r-- | src/libstd/num/i64.rs | 6 | ||||
| -rw-r--r-- | src/libstd/num/i8.rs | 6 | ||||
| -rw-r--r-- | src/libstd/num/int.rs | 12 | ||||
| -rw-r--r-- | src/libstd/num/int_macros.rs | 136 | ||||
| -rw-r--r-- | src/libstd/num/num.rs | 34 | ||||
| -rw-r--r-- | src/libstd/num/strconv.rs | 36 | ||||
| -rw-r--r-- | src/libstd/num/uint.rs | 4 | ||||
| -rw-r--r-- | src/libstd/num/uint_macros.rs | 130 |
13 files changed, 578 insertions, 578 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 7f981187300..117a474ffd7 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -20,7 +20,7 @@ use to_str; pub use cmath::c_float_targ_consts::*; -// An inner module is required to get the #[inline(always)] attribute on the +// An inner module is required to get the #[inline] attribute on the // functions. pub use self::delegated::*; @@ -40,7 +40,7 @@ macro_rules! delegate( use unstable::intrinsics; $( - #[inline(always)] + #[inline] pub fn $name($( $arg : $arg_ty ),*) -> $rv { unsafe { $bound_name($( $arg ),*) @@ -115,45 +115,45 @@ pub static infinity: f32 = 1.0_f32/0.0_f32; pub static neg_infinity: f32 = -1.0_f32/0.0_f32; -#[inline(always)] +#[inline] pub fn add(x: f32, y: f32) -> f32 { return x + y; } -#[inline(always)] +#[inline] pub fn sub(x: f32, y: f32) -> f32 { return x - y; } -#[inline(always)] +#[inline] pub fn mul(x: f32, y: f32) -> f32 { return x * y; } -#[inline(always)] +#[inline] pub fn div(x: f32, y: f32) -> f32 { return x / y; } -#[inline(always)] +#[inline] pub fn rem(x: f32, y: f32) -> f32 { return x % y; } -#[inline(always)] +#[inline] pub fn lt(x: f32, y: f32) -> bool { return x < y; } -#[inline(always)] +#[inline] pub fn le(x: f32, y: f32) -> bool { return x <= y; } -#[inline(always)] +#[inline] pub fn eq(x: f32, y: f32) -> bool { return x == y; } -#[inline(always)] +#[inline] pub fn ne(x: f32, y: f32) -> bool { return x != y; } -#[inline(always)] +#[inline] pub fn ge(x: f32, y: f32) -> bool { return x >= y; } -#[inline(always)] +#[inline] pub fn gt(x: f32, y: f32) -> bool { return x > y; } -#[inline(always)] +#[inline] pub fn fmax(x: f32, y: f32) -> f32 { if x >= y || y.is_NaN() { x } else { y } } -#[inline(always)] +#[inline] pub fn fmin(x: f32, y: f32) -> f32 { if x <= y || y.is_NaN() { x } else { y } } @@ -212,23 +212,23 @@ impl Num for f32 {} #[cfg(not(test))] impl Eq for f32 { - #[inline(always)] + #[inline] fn eq(&self, other: &f32) -> bool { (*self) == (*other) } - #[inline(always)] + #[inline] fn ne(&self, other: &f32) -> bool { (*self) != (*other) } } #[cfg(not(test))] impl ApproxEq<f32> for f32 { - #[inline(always)] + #[inline] fn approx_epsilon() -> f32 { 1.0e-6 } - #[inline(always)] + #[inline] fn approx_eq(&self, other: &f32) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::<f32, f32>()) } - #[inline(always)] + #[inline] fn approx_eq_eps(&self, other: &f32, approx_epsilon: &f32) -> bool { (*self - *other).abs() < *approx_epsilon } @@ -236,32 +236,32 @@ impl ApproxEq<f32> for f32 { #[cfg(not(test))] impl Ord for f32 { - #[inline(always)] + #[inline] fn lt(&self, other: &f32) -> bool { (*self) < (*other) } - #[inline(always)] + #[inline] fn le(&self, other: &f32) -> bool { (*self) <= (*other) } - #[inline(always)] + #[inline] fn ge(&self, other: &f32) -> bool { (*self) >= (*other) } - #[inline(always)] + #[inline] fn gt(&self, other: &f32) -> bool { (*self) > (*other) } } impl Orderable for f32 { /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline] fn min(&self, other: &f32) -> f32 { if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmin(*self, *other) } } /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline] fn max(&self, other: &f32) -> f32 { if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmax(*self, *other) } } /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. - #[inline(always)] + #[inline] fn clamp(&self, mn: &f32, mx: &f32) -> f32 { cond!( (self.is_NaN()) { *self } @@ -273,65 +273,65 @@ impl Orderable for f32 { } impl Zero for f32 { - #[inline(always)] + #[inline] fn zero() -> f32 { 0.0 } /// Returns true if the number is equal to either `0.0` or `-0.0` - #[inline(always)] + #[inline] fn is_zero(&self) -> bool { *self == 0.0 || *self == -0.0 } } impl One for f32 { - #[inline(always)] + #[inline] fn one() -> f32 { 1.0 } } #[cfg(not(test))] impl Add<f32,f32> for f32 { - #[inline(always)] + #[inline] fn add(&self, other: &f32) -> f32 { *self + *other } } #[cfg(not(test))] impl Sub<f32,f32> for f32 { - #[inline(always)] + #[inline] fn sub(&self, other: &f32) -> f32 { *self - *other } } #[cfg(not(test))] impl Mul<f32,f32> for f32 { - #[inline(always)] + #[inline] fn mul(&self, other: &f32) -> f32 { *self * *other } } #[cfg(not(test))] impl Div<f32,f32> for f32 { - #[inline(always)] + #[inline] fn div(&self, other: &f32) -> f32 { *self / *other } } #[cfg(not(test))] impl Rem<f32,f32> for f32 { - #[inline(always)] + #[inline] fn rem(&self, other: &f32) -> f32 { *self % *other } } #[cfg(not(test))] impl Neg<f32> for f32 { - #[inline(always)] + #[inline] fn neg(&self) -> f32 { -*self } } impl Signed for f32 { /// Computes the absolute value. Returns `NaN` if the number is `NaN`. - #[inline(always)] + #[inline] fn abs(&self) -> f32 { abs(*self) } /// /// The positive difference of two numbers. Returns `0.0` if the number is less than or /// equal to `other`, otherwise the difference between`self` and `other` is returned. /// - #[inline(always)] + #[inline] fn abs_sub(&self, other: &f32) -> f32 { abs_sub(*self, *other) } /// @@ -341,35 +341,35 @@ impl Signed for f32 { /// - `-1.0` if the number is negative, `-0.0` or `neg_infinity` /// - `NaN` if the number is NaN /// - #[inline(always)] + #[inline] fn signum(&self) -> f32 { if self.is_NaN() { NaN } else { copysign(1.0, *self) } } /// Returns `true` if the number is positive, including `+0.0` and `infinity` - #[inline(always)] + #[inline] fn is_positive(&self) -> bool { *self > 0.0 || (1.0 / *self) == infinity } /// Returns `true` if the number is negative, including `-0.0` and `neg_infinity` - #[inline(always)] + #[inline] fn is_negative(&self) -> bool { *self < 0.0 || (1.0 / *self) == neg_infinity } } impl Round for f32 { /// Round half-way cases toward `neg_infinity` - #[inline(always)] + #[inline] fn floor(&self) -> f32 { floor(*self) } /// Round half-way cases toward `infinity` - #[inline(always)] + #[inline] fn ceil(&self) -> f32 { ceil(*self) } /// Round half-way cases away from `0.0` - #[inline(always)] + #[inline] fn round(&self) -> f32 { round(*self) } /// The integer part of the number (rounds towards `0.0`) - #[inline(always)] + #[inline] fn trunc(&self) -> f32 { trunc(*self) } /// @@ -379,57 +379,57 @@ impl Round for f32 { /// assert!(x == trunc(x) + fract(x)) /// ~~~ /// - #[inline(always)] + #[inline] fn fract(&self) -> f32 { *self - self.trunc() } } impl Fractional for f32 { /// The reciprocal (multiplicative inverse) of the number - #[inline(always)] + #[inline] fn recip(&self) -> f32 { 1.0 / *self } } impl Algebraic for f32 { - #[inline(always)] + #[inline] fn pow(&self, n: &f32) -> f32 { pow(*self, *n) } - #[inline(always)] + #[inline] fn sqrt(&self) -> f32 { sqrt(*self) } - #[inline(always)] + #[inline] fn rsqrt(&self) -> f32 { self.sqrt().recip() } - #[inline(always)] + #[inline] fn cbrt(&self) -> f32 { cbrt(*self) } - #[inline(always)] + #[inline] fn hypot(&self, other: &f32) -> f32 { hypot(*self, *other) } } impl Trigonometric for f32 { - #[inline(always)] + #[inline] fn sin(&self) -> f32 { sin(*self) } - #[inline(always)] + #[inline] fn cos(&self) -> f32 { cos(*self) } - #[inline(always)] + #[inline] fn tan(&self) -> f32 { tan(*self) } - #[inline(always)] + #[inline] fn asin(&self) -> f32 { asin(*self) } - #[inline(always)] + #[inline] fn acos(&self) -> f32 { acos(*self) } - #[inline(always)] + #[inline] fn atan(&self) -> f32 { atan(*self) } - #[inline(always)] + #[inline] fn atan2(&self, other: &f32) -> f32 { atan2(*self, *other) } /// Simultaneously computes the sine and cosine of the number - #[inline(always)] + #[inline] fn sin_cos(&self) -> (f32, f32) { (self.sin(), self.cos()) } @@ -437,38 +437,38 @@ impl Trigonometric for f32 { impl Exponential for f32 { /// Returns the exponential of the number - #[inline(always)] + #[inline] fn exp(&self) -> f32 { exp(*self) } /// Returns 2 raised to the power of the number - #[inline(always)] + #[inline] fn exp2(&self) -> f32 { exp2(*self) } /// Returns the natural logarithm of the number - #[inline(always)] + #[inline] fn ln(&self) -> f32 { ln(*self) } /// Returns the logarithm of the number with respect to an arbitrary base - #[inline(always)] + #[inline] fn log(&self, base: &f32) -> f32 { self.ln() / base.ln() } /// Returns the base 2 logarithm of the number - #[inline(always)] + #[inline] fn log2(&self) -> f32 { log2(*self) } /// Returns the base 10 logarithm of the number - #[inline(always)] + #[inline] fn log10(&self) -> f32 { log10(*self) } } impl Hyperbolic for f32 { - #[inline(always)] + #[inline] fn sinh(&self) -> f32 { sinh(*self) } - #[inline(always)] + #[inline] fn cosh(&self) -> f32 { cosh(*self) } - #[inline(always)] + #[inline] fn tanh(&self) -> f32 { tanh(*self) } /// @@ -480,7 +480,7 @@ impl Hyperbolic for f32 { /// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity` /// - `NaN` if `self` is `NaN` /// - #[inline(always)] + #[inline] fn asinh(&self) -> f32 { match *self { neg_infinity => neg_infinity, @@ -497,7 +497,7 @@ impl Hyperbolic for f32 { /// - `infinity` if `self` is `infinity` /// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`) /// - #[inline(always)] + #[inline] fn acosh(&self) -> f32 { match *self { x if x < 1.0 => Float::NaN(), @@ -517,7 +517,7 @@ impl Hyperbolic for f32 { /// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0` /// (including `infinity` and `neg_infinity`) /// - #[inline(always)] + #[inline] fn atanh(&self) -> f32 { 0.5 * ((2.0 * *self) / (1.0 - *self)).ln_1p() } @@ -525,129 +525,129 @@ impl Hyperbolic for f32 { impl Real for f32 { /// Archimedes' constant - #[inline(always)] + #[inline] fn pi() -> f32 { 3.14159265358979323846264338327950288 } /// 2.0 * pi - #[inline(always)] + #[inline] fn two_pi() -> f32 { 6.28318530717958647692528676655900576 } /// pi / 2.0 - #[inline(always)] + #[inline] fn frac_pi_2() -> f32 { 1.57079632679489661923132169163975144 } /// pi / 3.0 - #[inline(always)] + #[inline] fn frac_pi_3() -> f32 { 1.04719755119659774615421446109316763 } /// pi / 4.0 - #[inline(always)] + #[inline] fn frac_pi_4() -> f32 { 0.785398163397448309615660845819875721 } /// pi / 6.0 - #[inline(always)] + #[inline] fn frac_pi_6() -> f32 { 0.52359877559829887307710723054658381 } /// pi / 8.0 - #[inline(always)] + #[inline] fn frac_pi_8() -> f32 { 0.39269908169872415480783042290993786 } /// 1 .0/ pi - #[inline(always)] + #[inline] fn frac_1_pi() -> f32 { 0.318309886183790671537767526745028724 } /// 2.0 / pi - #[inline(always)] + #[inline] fn frac_2_pi() -> f32 { 0.636619772367581343075535053490057448 } /// 2.0 / sqrt(pi) - #[inline(always)] + #[inline] fn frac_2_sqrtpi() -> f32 { 1.12837916709551257389615890312154517 } /// sqrt(2.0) - #[inline(always)] + #[inline] fn sqrt2() -> f32 { 1.41421356237309504880168872420969808 } /// 1.0 / sqrt(2.0) - #[inline(always)] + #[inline] fn frac_1_sqrt2() -> f32 { 0.707106781186547524400844362104849039 } /// Euler's number - #[inline(always)] + #[inline] fn e() -> f32 { 2.71828182845904523536028747135266250 } /// log2(e) - #[inline(always)] + #[inline] fn log2_e() -> f32 { 1.44269504088896340735992468100189214 } /// log10(e) - #[inline(always)] + #[inline] fn log10_e() -> f32 { 0.434294481903251827651128918916605082 } /// ln(2.0) - #[inline(always)] + #[inline] fn ln_2() -> f32 { 0.693147180559945309417232121458176568 } /// ln(10.0) - #[inline(always)] + #[inline] fn ln_10() -> f32 { 2.30258509299404568401799145468436421 } /// Converts to degrees, assuming the number is in radians - #[inline(always)] + #[inline] fn to_degrees(&self) -> f32 { *self * (180.0 / Real::pi::<f32>()) } /// Converts to radians, assuming the number is in degrees - #[inline(always)] + #[inline] fn to_radians(&self) -> f32 { *self * (Real::pi::<f32>() / 180.0) } } impl Bounded for f32 { - #[inline(always)] + #[inline] fn min_value() -> f32 { 1.17549435e-38 } - #[inline(always)] + #[inline] fn max_value() -> f32 { 3.40282347e+38 } } impl Primitive for f32 { - #[inline(always)] + #[inline] fn bits() -> uint { 32 } - #[inline(always)] + #[inline] fn bytes() -> uint { Primitive::bits::<f32>() / 8 } } impl Float for f32 { - #[inline(always)] + #[inline] fn NaN() -> f32 { 0.0 / 0.0 } - #[inline(always)] + #[inline] fn infinity() -> f32 { 1.0 / 0.0 } - #[inline(always)] + #[inline] fn neg_infinity() -> f32 { -1.0 / 0.0 } - #[inline(always)] + #[inline] fn neg_zero() -> f32 { -0.0 } /// Returns `true` if the number is NaN - #[inline(always)] + #[inline] fn is_NaN(&self) -> bool { *self != *self } /// Returns `true` if the number is infinite - #[inline(always)] + #[inline] fn is_infinite(&self) -> bool { *self == Float::infinity() || *self == Float::neg_infinity() } /// Returns `true` if the number is neither infinite or NaN - #[inline(always)] + #[inline] fn is_finite(&self) -> bool { !(self.is_NaN() || self.is_infinite()) } /// Returns `true` if the number is neither zero, infinite, subnormal or NaN - #[inline(always)] + #[inline] fn is_normal(&self) -> bool { self.classify() == FPNormal } @@ -670,29 +670,29 @@ impl Float for f32 { } } - #[inline(always)] + #[inline] fn mantissa_digits() -> uint { 24 } - #[inline(always)] + #[inline] fn digits() -> uint { 6 } - #[inline(always)] + #[inline] fn epsilon() -> f32 { 1.19209290e-07 } - #[inline(always)] + #[inline] fn min_exp() -> int { -125 } - #[inline(always)] + #[inline] fn max_exp() -> int { 128 } - #[inline(always)] + #[inline] fn min_10_exp() -> int { -37 } - #[inline(always)] + #[inline] fn max_10_exp() -> int { 38 } /// Constructs a floating point number by multiplying `x` by 2 raised to the power of `exp` - #[inline(always)] + #[inline] fn ldexp(x: f32, exp: int) -> f32 { ldexp(x, exp as c_int) } @@ -703,7 +703,7 @@ impl Float for f32 { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` /// - #[inline(always)] + #[inline] fn frexp(&self) -> (f32, int) { let mut exp = 0; let x = frexp(*self, &mut exp); @@ -714,14 +714,14 @@ impl Float for f32 { /// Returns the exponential of the number, minus `1`, in a way that is accurate /// even if the number is close to zero /// - #[inline(always)] + #[inline] fn exp_m1(&self) -> f32 { exp_m1(*self) } /// /// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately /// than if the operations were performed separately /// - #[inline(always)] + #[inline] fn ln_1p(&self) -> f32 { ln_1p(*self) } /// @@ -729,13 +729,13 @@ impl Float for f32 { /// produces a more accurate result with better performance than a separate multiplication /// operation followed by an add. /// - #[inline(always)] + #[inline] fn mul_add(&self, a: f32, b: f32) -> f32 { mul_add(*self, a, b) } /// Returns the next representable floating-point value in the direction of `other` - #[inline(always)] + #[inline] fn next_after(&self, other: f32) -> f32 { next_after(*self, other) } @@ -752,7 +752,7 @@ impl Float for f32 { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str(num: f32) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); @@ -766,7 +766,7 @@ pub fn to_str(num: f32) -> ~str { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str_hex(num: f32) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); @@ -787,7 +787,7 @@ pub fn to_str_hex(num: f32) -> ~str { /// possible misinterpretation of the result at higher bases. If those values /// are expected, use `to_str_radix_special()` instead. /// -#[inline(always)] +#[inline] pub fn to_str_radix(num: f32, rdx: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, rdx, true, strconv::SignNeg, strconv::DigAll); @@ -805,7 +805,7 @@ pub fn to_str_radix(num: f32, rdx: uint) -> ~str { /// * num - The float value /// * radix - The base to use /// -#[inline(always)] +#[inline] pub fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) { strconv::to_str_common(&num, rdx, true, strconv::SignNeg, strconv::DigAll) @@ -820,7 +820,7 @@ pub fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_exact(num: f32, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(dig)); @@ -836,7 +836,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> ~str { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_digits(num: f32, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(dig)); @@ -844,12 +844,12 @@ pub fn to_str_digits(num: f32, dig: uint) -> ~str { } impl to_str::ToStr for f32 { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for f32 { - #[inline(always)] + #[inline] fn to_str_radix(&self, rdx: uint) -> ~str { to_str_radix(*self, rdx) } @@ -882,7 +882,7 @@ impl num::ToStrRadix for f32 { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str(num: &str) -> Option<f32> { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false, false) @@ -915,7 +915,7 @@ pub fn from_str(num: &str) -> Option<f32> { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `[num]`. /// -#[inline(always)] +#[inline] pub fn from_str_hex(num: &str) -> Option<f32> { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false, false) @@ -940,19 +940,19 @@ pub fn from_str_hex(num: &str) -> Option<f32> { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str_radix(num: &str, rdx: uint) -> Option<f32> { strconv::from_str_common(num, rdx, true, true, false, strconv::ExpNone, false, false) } impl FromStr for f32 { - #[inline(always)] + #[inline] fn from_str(val: &str) -> Option<f32> { from_str(val) } } impl num::FromStrRadix for f32 { - #[inline(always)] + #[inline] fn from_str_radix(val: &str, rdx: uint) -> Option<f32> { from_str_radix(val, rdx) } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 6303e304576..e13dff1e623 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -22,7 +22,7 @@ use to_str; pub use cmath::c_double_targ_consts::*; pub use cmp::{min, max}; -// An inner module is required to get the #[inline(always)] attribute on the +// An inner module is required to get the #[inline] attribute on the // functions. pub use self::delegated::*; @@ -42,7 +42,7 @@ macro_rules! delegate( use unstable::intrinsics; $( - #[inline(always)] + #[inline] pub fn $name($( $arg : $arg_ty ),*) -> $rv { unsafe { $bound_name($( $arg ),*) @@ -141,45 +141,45 @@ pub static infinity: f64 = 1.0_f64/0.0_f64; pub static neg_infinity: f64 = -1.0_f64/0.0_f64; -#[inline(always)] +#[inline] pub fn add(x: f64, y: f64) -> f64 { return x + y; } -#[inline(always)] +#[inline] pub fn sub(x: f64, y: f64) -> f64 { return x - y; } -#[inline(always)] +#[inline] pub fn mul(x: f64, y: f64) -> f64 { return x * y; } -#[inline(always)] +#[inline] pub fn div(x: f64, y: f64) -> f64 { return x / y; } -#[inline(always)] +#[inline] pub fn rem(x: f64, y: f64) -> f64 { return x % y; } -#[inline(always)] +#[inline] pub fn lt(x: f64, y: f64) -> bool { return x < y; } -#[inline(always)] +#[inline] pub fn le(x: f64, y: f64) -> bool { return x <= y; } -#[inline(always)] +#[inline] pub fn eq(x: f64, y: f64) -> bool { return x == y; } -#[inline(always)] +#[inline] pub fn ne(x: f64, y: f64) -> bool { return x != y; } -#[inline(always)] +#[inline] pub fn ge(x: f64, y: f64) -> bool { return x >= y; } -#[inline(always)] +#[inline] pub fn gt(x: f64, y: f64) -> bool { return x > y; } -#[inline(always)] +#[inline] pub fn fmax(x: f64, y: f64) -> f64 { if x >= y || y.is_NaN() { x } else { y } } -#[inline(always)] +#[inline] pub fn fmin(x: f64, y: f64) -> f64 { if x <= y || y.is_NaN() { x } else { y } } @@ -234,23 +234,23 @@ impl Num for f64 {} #[cfg(not(test))] impl Eq for f64 { - #[inline(always)] + #[inline] fn eq(&self, other: &f64) -> bool { (*self) == (*other) } - #[inline(always)] + #[inline] fn ne(&self, other: &f64) -> bool { (*self) != (*other) } } #[cfg(not(test))] impl ApproxEq<f64> for f64 { - #[inline(always)] + #[inline] fn approx_epsilon() -> f64 { 1.0e-6 } - #[inline(always)] + #[inline] fn approx_eq(&self, other: &f64) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::<f64, f64>()) } - #[inline(always)] + #[inline] fn approx_eq_eps(&self, other: &f64, approx_epsilon: &f64) -> bool { (*self - *other).abs() < *approx_epsilon } @@ -258,32 +258,32 @@ impl ApproxEq<f64> for f64 { #[cfg(not(test))] impl Ord for f64 { - #[inline(always)] + #[inline] fn lt(&self, other: &f64) -> bool { (*self) < (*other) } - #[inline(always)] + #[inline] fn le(&self, other: &f64) -> bool { (*self) <= (*other) } - #[inline(always)] + #[inline] fn ge(&self, other: &f64) -> bool { (*self) >= (*other) } - #[inline(always)] + #[inline] fn gt(&self, other: &f64) -> bool { (*self) > (*other) } } impl Orderable for f64 { /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline] fn min(&self, other: &f64) -> f64 { if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmin(*self, *other) } } /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline] fn max(&self, other: &f64) -> f64 { if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmax(*self, *other) } } /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. - #[inline(always)] + #[inline] fn clamp(&self, mn: &f64, mx: &f64) -> f64 { cond!( (self.is_NaN()) { *self } @@ -295,16 +295,16 @@ impl Orderable for f64 { } impl Zero for f64 { - #[inline(always)] + #[inline] fn zero() -> f64 { 0.0 } /// Returns true if the number is equal to either `0.0` or `-0.0` - #[inline(always)] + #[inline] fn is_zero(&self) -> bool { *self == 0.0 || *self == -0.0 } } impl One for f64 { - #[inline(always)] + #[inline] fn one() -> f64 { 1.0 } } @@ -326,7 +326,7 @@ impl Div<f64,f64> for f64 { } #[cfg(not(test))] impl Rem<f64,f64> for f64 { - #[inline(always)] + #[inline] fn rem(&self, other: &f64) -> f64 { *self % *other } } #[cfg(not(test))] @@ -336,14 +336,14 @@ impl Neg<f64> for f64 { impl Signed for f64 { /// Computes the absolute value. Returns `NaN` if the number is `NaN`. - #[inline(always)] + #[inline] fn abs(&self) -> f64 { abs(*self) } /// /// The positive difference of two numbers. Returns `0.0` if the number is less than or /// equal to `other`, otherwise the difference between`self` and `other` is returned. /// - #[inline(always)] + #[inline] fn abs_sub(&self, other: &f64) -> f64 { abs_sub(*self, *other) } /// @@ -353,35 +353,35 @@ impl Signed for f64 { /// - `-1.0` if the number is negative, `-0.0` or `neg_infinity` /// - `NaN` if the number is NaN /// - #[inline(always)] + #[inline] fn signum(&self) -> f64 { if self.is_NaN() { NaN } else { copysign(1.0, *self) } } /// Returns `true` if the number is positive, including `+0.0` and `infinity` - #[inline(always)] + #[inline] fn is_positive(&self) -> bool { *self > 0.0 || (1.0 / *self) == infinity } /// Returns `true` if the number is negative, including `-0.0` and `neg_infinity` - #[inline(always)] + #[inline] fn is_negative(&self) -> bool { *self < 0.0 || (1.0 / *self) == neg_infinity } } impl Round for f64 { /// Round half-way cases toward `neg_infinity` - #[inline(always)] + #[inline] fn floor(&self) -> f64 { floor(*self) } /// Round half-way cases toward `infinity` - #[inline(always)] + #[inline] fn ceil(&self) -> f64 { ceil(*self) } /// Round half-way cases away from `0.0` - #[inline(always)] + #[inline] fn round(&self) -> f64 { round(*self) } /// The integer part of the number (rounds towards `0.0`) - #[inline(always)] + #[inline] fn trunc(&self) -> f64 { trunc(*self) } /// @@ -391,57 +391,57 @@ impl Round for f64 { /// assert!(x == trunc(x) + fract(x)) /// ~~~ /// - #[inline(always)] + #[inline] fn fract(&self) -> f64 { *self - self.trunc() } } impl Fractional for f64 { /// The reciprocal (multiplicative inverse) of the number - #[inline(always)] + #[inline] fn recip(&self) -> f64 { 1.0 / *self } } impl Algebraic for f64 { - #[inline(always)] + #[inline] fn pow(&self, n: &f64) -> f64 { pow(*self, *n) } - #[inline(always)] + #[inline] fn sqrt(&self) -> f64 { sqrt(*self) } - #[inline(always)] + #[inline] fn rsqrt(&self) -> f64 { self.sqrt().recip() } - #[inline(always)] + #[inline] fn cbrt(&self) -> f64 { cbrt(*self) } - #[inline(always)] + #[inline] fn hypot(&self, other: &f64) -> f64 { hypot(*self, *other) } } impl Trigonometric for f64 { - #[inline(always)] + #[inline] fn sin(&self) -> f64 { sin(*self) } - #[inline(always)] + #[inline] fn cos(&self) -> f64 { cos(*self) } - #[inline(always)] + #[inline] fn tan(&self) -> f64 { tan(*self) } - #[inline(always)] + #[inline] fn asin(&self) -> f64 { asin(*self) } - #[inline(always)] + #[inline] fn acos(&self) -> f64 { acos(*self) } - #[inline(always)] + #[inline] fn atan(&self) -> f64 { atan(*self) } - #[inline(always)] + #[inline] fn atan2(&self, other: &f64) -> f64 { atan2(*self, *other) } /// Simultaneously computes the sine and cosine of the number - #[inline(always)] + #[inline] fn sin_cos(&self) -> (f64, f64) { (self.sin(), self.cos()) } @@ -449,38 +449,38 @@ impl Trigonometric for f64 { impl Exponential for f64 { /// Returns the exponential of the number - #[inline(always)] + #[inline] fn exp(&self) -> f64 { exp(*self) } /// Returns 2 raised to the power of the number - #[inline(always)] + #[inline] fn exp2(&self) -> f64 { exp2(*self) } /// Returns the natural logarithm of the number - #[inline(always)] + #[inline] fn ln(&self) -> f64 { ln(*self) } /// Returns the logarithm of the number with respect to an arbitrary base - #[inline(always)] + #[inline] fn log(&self, base: &f64) -> f64 { self.ln() / base.ln() } /// Returns the base 2 logarithm of the number - #[inline(always)] + #[inline] fn log2(&self) -> f64 { log2(*self) } /// Returns the base 10 logarithm of the number - #[inline(always)] + #[inline] fn log10(&self) -> f64 { log10(*self) } } impl Hyperbolic for f64 { - #[inline(always)] + #[inline] fn sinh(&self) -> f64 { sinh(*self) } - #[inline(always)] + #[inline] fn cosh(&self) -> f64 { cosh(*self) } - #[inline(always)] + #[inline] fn tanh(&self) -> f64 { tanh(*self) } /// @@ -492,7 +492,7 @@ impl Hyperbolic for f64 { /// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity` /// - `NaN` if `self` is `NaN` /// - #[inline(always)] + #[inline] fn asinh(&self) -> f64 { match *self { neg_infinity => neg_infinity, @@ -509,7 +509,7 @@ impl Hyperbolic for f64 { /// - `infinity` if `self` is `infinity` /// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`) /// - #[inline(always)] + #[inline] fn acosh(&self) -> f64 { match *self { x if x < 1.0 => Float::NaN(), @@ -529,7 +529,7 @@ impl Hyperbolic for f64 { /// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0` /// (including `infinity` and `neg_infinity`) /// - #[inline(always)] + #[inline] fn atanh(&self) -> f64 { 0.5 * ((2.0 * *self) / (1.0 - *self)).ln_1p() } @@ -537,159 +537,159 @@ impl Hyperbolic for f64 { impl Real for f64 { /// Archimedes' constant - #[inline(always)] + #[inline] fn pi() -> f64 { 3.14159265358979323846264338327950288 } /// 2.0 * pi - #[inline(always)] + #[inline] fn two_pi() -> f64 { 6.28318530717958647692528676655900576 } /// pi / 2.0 - #[inline(always)] + #[inline] fn frac_pi_2() -> f64 { 1.57079632679489661923132169163975144 } /// pi / 3.0 - #[inline(always)] + #[inline] fn frac_pi_3() -> f64 { 1.04719755119659774615421446109316763 } /// pi / 4.0 - #[inline(always)] + #[inline] fn frac_pi_4() -> f64 { 0.785398163397448309615660845819875721 } /// pi / 6.0 - #[inline(always)] + #[inline] fn frac_pi_6() -> f64 { 0.52359877559829887307710723054658381 } /// pi / 8.0 - #[inline(always)] + #[inline] fn frac_pi_8() -> f64 { 0.39269908169872415480783042290993786 } /// 1.0 / pi - #[inline(always)] + #[inline] fn frac_1_pi() -> f64 { 0.318309886183790671537767526745028724 } /// 2.0 / pi - #[inline(always)] + #[inline] fn frac_2_pi() -> f64 { 0.636619772367581343075535053490057448 } /// 2.0 / sqrt(pi) - #[inline(always)] + #[inline] fn frac_2_sqrtpi() -> f64 { 1.12837916709551257389615890312154517 } /// sqrt(2.0) - #[inline(always)] + #[inline] fn sqrt2() -> f64 { 1.41421356237309504880168872420969808 } /// 1.0 / sqrt(2.0) - #[inline(always)] + #[inline] fn frac_1_sqrt2() -> f64 { 0.707106781186547524400844362104849039 } /// Euler's number - #[inline(always)] + #[inline] fn e() -> f64 { 2.71828182845904523536028747135266250 } /// log2(e) - #[inline(always)] + #[inline] fn log2_e() -> f64 { 1.44269504088896340735992468100189214 } /// log10(e) - #[inline(always)] + #[inline] fn log10_e() -> f64 { 0.434294481903251827651128918916605082 } /// ln(2.0) - #[inline(always)] + #[inline] fn ln_2() -> f64 { 0.693147180559945309417232121458176568 } /// ln(10.0) - #[inline(always)] + #[inline] fn ln_10() -> f64 { 2.30258509299404568401799145468436421 } /// Converts to degrees, assuming the number is in radians - #[inline(always)] + #[inline] fn to_degrees(&self) -> f64 { *self * (180.0 / Real::pi::<f64>()) } /// Converts to radians, assuming the number is in degrees - #[inline(always)] + #[inline] fn to_radians(&self) -> f64 { *self * (Real::pi::<f64>() / 180.0) } } impl RealExt for f64 { - #[inline(always)] + #[inline] fn lgamma(&self) -> (int, f64) { let mut sign = 0; let result = lgamma(*self, &mut sign); (sign as int, result) } - #[inline(always)] + #[inline] fn tgamma(&self) -> f64 { tgamma(*self) } - #[inline(always)] + #[inline] fn j0(&self) -> f64 { j0(*self) } - #[inline(always)] + #[inline] fn j1(&self) -> f64 { j1(*self) } - #[inline(always)] + #[inline] fn jn(&self, n: int) -> f64 { jn(n as c_int, *self) } - #[inline(always)] + #[inline] fn y0(&self) -> f64 { y0(*self) } - #[inline(always)] + #[inline] fn y1(&self) -> f64 { y1(*self) } - #[inline(always)] + #[inline] fn yn(&self, n: int) -> f64 { yn(n as c_int, *self) } } impl Bounded for f64 { - #[inline(always)] + #[inline] fn min_value() -> f64 { 2.2250738585072014e-308 } - #[inline(always)] + #[inline] fn max_value() -> f64 { 1.7976931348623157e+308 } } impl Primitive for f64 { - #[inline(always)] + #[inline] fn bits() -> uint { 64 } - #[inline(always)] + #[inline] fn bytes() -> uint { Primitive::bits::<f64>() / 8 } } impl Float for f64 { - #[inline(always)] + #[inline] fn NaN() -> f64 { 0.0 / 0.0 } - #[inline(always)] + #[inline] fn infinity() -> f64 { 1.0 / 0.0 } - #[inline(always)] + #[inline] fn neg_infinity() -> f64 { -1.0 / 0.0 } - #[inline(always)] + #[inline] fn neg_zero() -> f64 { -0.0 } /// Returns `true` if the number is NaN - #[inline(always)] + #[inline] fn is_NaN(&self) -> bool { *self != *self } /// Returns `true` if the number is infinite - #[inline(always)] + #[inline] fn is_infinite(&self) -> bool { *self == Float::infinity() || *self == Float::neg_infinity() } /// Returns `true` if the number is neither infinite or NaN - #[inline(always)] + #[inline] fn is_finite(&self) -> bool { !(self.is_NaN() || self.is_infinite()) } /// Returns `true` if the number is neither zero, infinite, subnormal or NaN - #[inline(always)] + #[inline] fn is_normal(&self) -> bool { self.classify() == FPNormal } @@ -712,29 +712,29 @@ impl Float for f64 { } } - #[inline(always)] + #[inline] fn mantissa_digits() -> uint { 53 } - #[inline(always)] + #[inline] fn digits() -> uint { 15 } - #[inline(always)] + #[inline] fn epsilon() -> f64 { 2.2204460492503131e-16 } - #[inline(always)] + #[inline] fn min_exp() -> int { -1021 } - #[inline(always)] + #[inline] fn max_exp() -> int { 1024 } - #[inline(always)] + #[inline] fn min_10_exp() -> int { -307 } - #[inline(always)] + #[inline] fn max_10_exp() -> int { 308 } /// Constructs a floating point number by multiplying `x` by 2 raised to the power of `exp` - #[inline(always)] + #[inline] fn ldexp(x: f64, exp: int) -> f64 { ldexp(x, exp as c_int) } @@ -745,7 +745,7 @@ impl Float for f64 { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` /// - #[inline(always)] + #[inline] fn frexp(&self) -> (f64, int) { let mut exp = 0; let x = frexp(*self, &mut exp); @@ -756,14 +756,14 @@ impl Float for f64 { /// Returns the exponential of the number, minus `1`, in a way that is accurate /// even if the number is close to zero /// - #[inline(always)] + #[inline] fn exp_m1(&self) -> f64 { exp_m1(*self) } /// /// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately /// than if the operations were performed separately /// - #[inline(always)] + #[inline] fn ln_1p(&self) -> f64 { ln_1p(*self) } /// @@ -771,13 +771,13 @@ impl Float for f64 { /// produces a more accurate result with better performance than a separate multiplication /// operation followed by an add. /// - #[inline(always)] + #[inline] fn mul_add(&self, a: f64, b: f64) -> f64 { mul_add(*self, a, b) } /// Returns the next representable floating-point value in the direction of `other` - #[inline(always)] + #[inline] fn next_after(&self, other: f64) -> f64 { next_after(*self, other) } @@ -794,7 +794,7 @@ impl Float for f64 { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str(num: f64) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); @@ -808,7 +808,7 @@ pub fn to_str(num: f64) -> ~str { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str_hex(num: f64) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); @@ -829,7 +829,7 @@ pub fn to_str_hex(num: f64) -> ~str { /// possible misinterpretation of the result at higher bases. If those values /// are expected, use `to_str_radix_special()` instead. /// -#[inline(always)] +#[inline] pub fn to_str_radix(num: f64, rdx: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, rdx, true, strconv::SignNeg, strconv::DigAll); @@ -847,7 +847,7 @@ pub fn to_str_radix(num: f64, rdx: uint) -> ~str { /// * num - The float value /// * radix - The base to use /// -#[inline(always)] +#[inline] pub fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) { strconv::to_str_common(&num, rdx, true, strconv::SignNeg, strconv::DigAll) @@ -862,7 +862,7 @@ pub fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_exact(num: f64, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(dig)); @@ -878,7 +878,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> ~str { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_digits(num: f64, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(dig)); @@ -886,12 +886,12 @@ pub fn to_str_digits(num: f64, dig: uint) -> ~str { } impl to_str::ToStr for f64 { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for f64 { - #[inline(always)] + #[inline] fn to_str_radix(&self, rdx: uint) -> ~str { to_str_radix(*self, rdx) } @@ -924,7 +924,7 @@ impl num::ToStrRadix for f64 { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str(num: &str) -> Option<f64> { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false, false) @@ -957,7 +957,7 @@ pub fn from_str(num: &str) -> Option<f64> { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `[num]`. /// -#[inline(always)] +#[inline] pub fn from_str_hex(num: &str) -> Option<f64> { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false, false) @@ -982,19 +982,19 @@ pub fn from_str_hex(num: &str) -> Option<f64> { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str_radix(num: &str, rdx: uint) -> Option<f64> { strconv::from_str_common(num, rdx, true, true, false, strconv::ExpNone, false, false) } impl FromStr for f64 { - #[inline(always)] + #[inline] fn from_str(val: &str) -> Option<f64> { from_str(val) } } impl num::FromStrRadix for f64 { - #[inline(always)] + #[inline] fn from_str_radix(val: &str, rdx: uint) -> Option<f64> { from_str_radix(val, rdx) } diff --git a/src/libstd/num/float.rs b/src/libstd/num/float.rs index 267a8890e82..c583aeacf16 100644 --- a/src/libstd/num/float.rs +++ b/src/libstd/num/float.rs @@ -99,7 +99,7 @@ pub mod consts { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str(num: float) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); @@ -113,7 +113,7 @@ pub fn to_str(num: float) -> ~str { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str_hex(num: float) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); @@ -134,7 +134,7 @@ pub fn to_str_hex(num: float) -> ~str { /// possible misinterpretation of the result at higher bases. If those values /// are expected, use `to_str_radix_special()` instead. /// -#[inline(always)] +#[inline] pub fn to_str_radix(num: float, radix: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, radix, true, strconv::SignNeg, strconv::DigAll); @@ -152,7 +152,7 @@ pub fn to_str_radix(num: float, radix: uint) -> ~str { /// * num - The float value /// * radix - The base to use /// -#[inline(always)] +#[inline] pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { strconv::to_str_common(&num, radix, true, strconv::SignNeg, strconv::DigAll) @@ -167,7 +167,7 @@ pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_exact(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(digits)); @@ -183,7 +183,7 @@ pub fn to_str_exact(num: float, digits: uint) -> ~str { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_digits(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(digits)); @@ -191,12 +191,12 @@ pub fn to_str_digits(num: float, digits: uint) -> ~str { } impl to_str::ToStr for float { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for float { - #[inline(always)] + #[inline] fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } @@ -229,7 +229,7 @@ impl num::ToStrRadix for float { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str(num: &str) -> Option<float> { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false, false) @@ -262,7 +262,7 @@ pub fn from_str(num: &str) -> Option<float> { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `[num]`. /// -#[inline(always)] +#[inline] pub fn from_str_hex(num: &str) -> Option<float> { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false, false) @@ -287,19 +287,19 @@ pub fn from_str_hex(num: &str) -> Option<float> { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str_radix(num: &str, radix: uint) -> Option<float> { strconv::from_str_common(num, radix, true, true, false, strconv::ExpNone, false, false) } impl FromStr for float { - #[inline(always)] + #[inline] fn from_str(val: &str) -> Option<float> { from_str(val) } } impl num::FromStrRadix for float { - #[inline(always)] + #[inline] fn from_str_radix(val: &str, radix: uint) -> Option<float> { from_str_radix(val, radix) } @@ -341,27 +341,27 @@ pub fn pow_with_uint(base: uint, pow: uint) -> float { return total; } -#[inline(always)] +#[inline] pub fn abs(x: float) -> float { f64::abs(x as f64) as float } -#[inline(always)] +#[inline] pub fn sqrt(x: float) -> float { f64::sqrt(x as f64) as float } -#[inline(always)] +#[inline] pub fn atan(x: float) -> float { f64::atan(x as f64) as float } -#[inline(always)] +#[inline] pub fn sin(x: float) -> float { f64::sin(x as f64) as float } -#[inline(always)] +#[inline] pub fn cos(x: float) -> float { f64::cos(x as f64) as float } -#[inline(always)] +#[inline] pub fn tan(x: float) -> float { f64::tan(x as f64) as float } @@ -370,23 +370,23 @@ impl Num for float {} #[cfg(not(test))] impl Eq for float { - #[inline(always)] + #[inline] fn eq(&self, other: &float) -> bool { (*self) == (*other) } - #[inline(always)] + #[inline] fn ne(&self, other: &float) -> bool { (*self) != (*other) } } #[cfg(not(test))] impl ApproxEq<float> for float { - #[inline(always)] + #[inline] fn approx_epsilon() -> float { 1.0e-6 } - #[inline(always)] + #[inline] fn approx_eq(&self, other: &float) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::<float, float>()) } - #[inline(always)] + #[inline] fn approx_eq_eps(&self, other: &float, approx_epsilon: &float) -> bool { (*self - *other).abs() < *approx_epsilon } @@ -394,66 +394,66 @@ impl ApproxEq<float> for float { #[cfg(not(test))] impl Ord for float { - #[inline(always)] + #[inline] fn lt(&self, other: &float) -> bool { (*self) < (*other) } - #[inline(always)] + #[inline] fn le(&self, other: &float) -> bool { (*self) <= (*other) } - #[inline(always)] + #[inline] fn ge(&self, other: &float) -> bool { (*self) >= (*other) } - #[inline(always)] + #[inline] fn gt(&self, other: &float) -> bool { (*self) > (*other) } } impl Orderable for float { /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline] fn min(&self, other: &float) -> float { (*self as f64).min(&(*other as f64)) as float } /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline] fn max(&self, other: &float) -> float { (*self as f64).max(&(*other as f64)) as float } /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. - #[inline(always)] + #[inline] fn clamp(&self, mn: &float, mx: &float) -> float { (*self as f64).clamp(&(*mn as f64), &(*mx as f64)) as float } } impl Zero for float { - #[inline(always)] + #[inline] fn zero() -> float { 0.0 } /// Returns true if the number is equal to either `0.0` or `-0.0` - #[inline(always)] + #[inline] fn is_zero(&self) -> bool { *self == 0.0 || *self == -0.0 } } impl One for float { - #[inline(always)] + #[inline] fn one() -> float { 1.0 } } impl Round for float { /// Round half-way cases toward `neg_infinity` - #[inline(always)] + #[inline] fn floor(&self) -> float { floor(*self as f64) as float } /// Round half-way cases toward `infinity` - #[inline(always)] + #[inline] fn ceil(&self) -> float { ceil(*self as f64) as float } /// Round half-way cases away from `0.0` - #[inline(always)] + #[inline] fn round(&self) -> float { round(*self as f64) as float } /// The integer part of the number (rounds towards `0.0`) - #[inline(always)] + #[inline] fn trunc(&self) -> float { trunc(*self as f64) as float } /// @@ -463,81 +463,81 @@ impl Round for float { /// assert!(x == trunc(x) + fract(x)) /// ~~~ /// - #[inline(always)] + #[inline] fn fract(&self) -> float { *self - self.trunc() } } impl Fractional for float { /// The reciprocal (multiplicative inverse) of the number - #[inline(always)] + #[inline] fn recip(&self) -> float { 1.0 / *self } } impl Algebraic for float { - #[inline(always)] + #[inline] fn pow(&self, n: &float) -> float { (*self as f64).pow(&(*n as f64)) as float } - #[inline(always)] + #[inline] fn sqrt(&self) -> float { (*self as f64).sqrt() as float } - #[inline(always)] + #[inline] fn rsqrt(&self) -> float { (*self as f64).rsqrt() as float } - #[inline(always)] + #[inline] fn cbrt(&self) -> float { (*self as f64).cbrt() as float } - #[inline(always)] + #[inline] fn hypot(&self, other: &float) -> float { (*self as f64).hypot(&(*other as f64)) as float } } impl Trigonometric for float { - #[inline(always)] + #[inline] fn sin(&self) -> float { (*self as f64).sin() as float } - #[inline(always)] + #[inline] fn cos(&self) -> float { (*self as f64).cos() as float } - #[inline(always)] + #[inline] fn tan(&self) -> float { (*self as f64).tan() as float } - #[inline(always)] + #[inline] fn asin(&self) -> float { (*self as f64).asin() as float } - #[inline(always)] + #[inline] fn acos(&self) -> float { (*self as f64).acos() as float } - #[inline(always)] + #[inline] fn atan(&self) -> float { (*self as f64).atan() as float } - #[inline(always)] + #[inline] fn atan2(&self, other: &float) -> float { (*self as f64).atan2(&(*other as f64)) as float } /// Simultaneously computes the sine and cosine of the number - #[inline(always)] + #[inline] fn sin_cos(&self) -> (float, float) { match (*self as f64).sin_cos() { (s, c) => (s as float, c as float) @@ -547,54 +547,54 @@ impl Trigonometric for float { impl Exponential for float { /// Returns the exponential of the number - #[inline(always)] + #[inline] fn exp(&self) -> float { (*self as f64).exp() as float } /// Returns 2 raised to the power of the number - #[inline(always)] + #[inline] fn exp2(&self) -> float { (*self as f64).exp2() as float } /// Returns the natural logarithm of the number - #[inline(always)] + #[inline] fn ln(&self) -> float { (*self as f64).ln() as float } /// Returns the logarithm of the number with respect to an arbitrary base - #[inline(always)] + #[inline] fn log(&self, base: &float) -> float { (*self as f64).log(&(*base as f64)) as float } /// Returns the base 2 logarithm of the number - #[inline(always)] + #[inline] fn log2(&self) -> float { (*self as f64).log2() as float } /// Returns the base 10 logarithm of the number - #[inline(always)] + #[inline] fn log10(&self) -> float { (*self as f64).log10() as float } } impl Hyperbolic for float { - #[inline(always)] + #[inline] fn sinh(&self) -> float { (*self as f64).sinh() as float } - #[inline(always)] + #[inline] fn cosh(&self) -> float { (*self as f64).cosh() as float } - #[inline(always)] + #[inline] fn tanh(&self) -> float { (*self as f64).tanh() as float } @@ -608,7 +608,7 @@ impl Hyperbolic for float { /// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity` /// - `NaN` if `self` is `NaN` /// - #[inline(always)] + #[inline] fn asinh(&self) -> float { (*self as f64).asinh() as float } @@ -622,7 +622,7 @@ impl Hyperbolic for float { /// - `infinity` if `self` is `infinity` /// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`) /// - #[inline(always)] + #[inline] fn acosh(&self) -> float { (*self as f64).acosh() as float } @@ -639,7 +639,7 @@ impl Hyperbolic for float { /// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0` /// (including `infinity` and `neg_infinity`) /// - #[inline(always)] + #[inline] fn atanh(&self) -> float { (*self as f64).atanh() as float } @@ -647,157 +647,157 @@ impl Hyperbolic for float { impl Real for float { /// Archimedes' constant - #[inline(always)] + #[inline] fn pi() -> float { 3.14159265358979323846264338327950288 } /// 2.0 * pi - #[inline(always)] + #[inline] fn two_pi() -> float { 6.28318530717958647692528676655900576 } /// pi / 2.0 - #[inline(always)] + #[inline] fn frac_pi_2() -> float { 1.57079632679489661923132169163975144 } /// pi / 3.0 - #[inline(always)] + #[inline] fn frac_pi_3() -> float { 1.04719755119659774615421446109316763 } /// pi / 4.0 - #[inline(always)] + #[inline] fn frac_pi_4() -> float { 0.785398163397448309615660845819875721 } /// pi / 6.0 - #[inline(always)] + #[inline] fn frac_pi_6() -> float { 0.52359877559829887307710723054658381 } /// pi / 8.0 - #[inline(always)] + #[inline] fn frac_pi_8() -> float { 0.39269908169872415480783042290993786 } /// 1.0 / pi - #[inline(always)] + #[inline] fn frac_1_pi() -> float { 0.318309886183790671537767526745028724 } /// 2.0 / pi - #[inline(always)] + #[inline] fn frac_2_pi() -> float { 0.636619772367581343075535053490057448 } /// 2 .0/ sqrt(pi) - #[inline(always)] + #[inline] fn frac_2_sqrtpi() -> float { 1.12837916709551257389615890312154517 } /// sqrt(2.0) - #[inline(always)] + #[inline] fn sqrt2() -> float { 1.41421356237309504880168872420969808 } /// 1.0 / sqrt(2.0) - #[inline(always)] + #[inline] fn frac_1_sqrt2() -> float { 0.707106781186547524400844362104849039 } /// Euler's number - #[inline(always)] + #[inline] fn e() -> float { 2.71828182845904523536028747135266250 } /// log2(e) - #[inline(always)] + #[inline] fn log2_e() -> float { 1.44269504088896340735992468100189214 } /// log10(e) - #[inline(always)] + #[inline] fn log10_e() -> float { 0.434294481903251827651128918916605082 } /// ln(2.0) - #[inline(always)] + #[inline] fn ln_2() -> float { 0.693147180559945309417232121458176568 } /// ln(10.0) - #[inline(always)] + #[inline] fn ln_10() -> float { 2.30258509299404568401799145468436421 } /// Converts to degrees, assuming the number is in radians - #[inline(always)] + #[inline] fn to_degrees(&self) -> float { (*self as f64).to_degrees() as float } /// Converts to radians, assuming the number is in degrees - #[inline(always)] + #[inline] fn to_radians(&self) -> float { (*self as f64).to_radians() as float } } impl RealExt for float { - #[inline(always)] + #[inline] fn lgamma(&self) -> (int, float) { let mut sign = 0; let result = lgamma(*self as f64, &mut sign); (sign as int, result as float) } - #[inline(always)] + #[inline] fn tgamma(&self) -> float { tgamma(*self as f64) as float } - #[inline(always)] + #[inline] fn j0(&self) -> float { j0(*self as f64) as float } - #[inline(always)] + #[inline] fn j1(&self) -> float { j1(*self as f64) as float } - #[inline(always)] + #[inline] fn jn(&self, n: int) -> float { jn(n as c_int, *self as f64) as float } - #[inline(always)] + #[inline] fn y0(&self) -> float { y0(*self as f64) as float } - #[inline(always)] + #[inline] fn y1(&self) -> float { y1(*self as f64) as float } - #[inline(always)] + #[inline] fn yn(&self, n: int) -> float { yn(n as c_int, *self as f64) as float } } #[cfg(not(test))] impl Add<float,float> for float { - #[inline(always)] + #[inline] fn add(&self, other: &float) -> float { *self + *other } } #[cfg(not(test))] impl Sub<float,float> for float { - #[inline(always)] + #[inline] fn sub(&self, other: &float) -> float { *self - *other } } #[cfg(not(test))] impl Mul<float,float> for float { - #[inline(always)] + #[inline] fn mul(&self, other: &float) -> float { *self * *other } } #[cfg(not(test))] impl Div<float,float> for float { - #[inline(always)] + #[inline] fn div(&self, other: &float) -> float { *self / *other } } #[cfg(not(test))] impl Rem<float,float> for float { - #[inline(always)] + #[inline] fn rem(&self, other: &float) -> float { *self % *other } } #[cfg(not(test))] impl Neg<float> for float { - #[inline(always)] + #[inline] fn neg(&self) -> float { -*self } } impl Signed for float { /// Computes the absolute value. Returns `NaN` if the number is `NaN`. - #[inline(always)] + #[inline] fn abs(&self) -> float { abs(*self) } /// /// The positive difference of two numbers. Returns `0.0` if the number is less than or /// equal to `other`, otherwise the difference between`self` and `other` is returned. /// - #[inline(always)] + #[inline] fn abs_sub(&self, other: &float) -> float { (*self as f64).abs_sub(&(*other as f64)) as float } @@ -809,93 +809,93 @@ impl Signed for float { /// - `-1.0` if the number is negative, `-0.0` or `neg_infinity` /// - `NaN` if the number is NaN /// - #[inline(always)] + #[inline] fn signum(&self) -> float { if self.is_NaN() { NaN } else { f64::copysign(1.0, *self as f64) as float } } /// Returns `true` if the number is positive, including `+0.0` and `infinity` - #[inline(always)] + #[inline] fn is_positive(&self) -> bool { *self > 0.0 || (1.0 / *self) == infinity } /// Returns `true` if the number is negative, including `-0.0` and `neg_infinity` - #[inline(always)] + #[inline] fn is_negative(&self) -> bool { *self < 0.0 || (1.0 / *self) == neg_infinity } } impl Bounded for float { - #[inline(always)] + #[inline] fn min_value() -> float { Bounded::min_value::<f64>() as float } - #[inline(always)] + #[inline] fn max_value() -> float { Bounded::max_value::<f64>() as float } } impl Primitive for float { - #[inline(always)] + #[inline] fn bits() -> uint { Primitive::bits::<f64>() } - #[inline(always)] + #[inline] fn bytes() -> uint { Primitive::bytes::<f64>() } } impl Float for float { - #[inline(always)] + #[inline] fn NaN() -> float { Float::NaN::<f64>() as float } - #[inline(always)] + #[inline] fn infinity() -> float { Float::infinity::<f64>() as float } - #[inline(always)] + #[inline] fn neg_infinity() -> float { Float::neg_infinity::<f64>() as float } - #[inline(always)] + #[inline] fn neg_zero() -> float { Float::neg_zero::<f64>() as float } /// Returns `true` if the number is NaN - #[inline(always)] + #[inline] fn is_NaN(&self) -> bool { (*self as f64).is_NaN() } /// Returns `true` if the number is infinite - #[inline(always)] + #[inline] fn is_infinite(&self) -> bool { (*self as f64).is_infinite() } /// Returns `true` if the number is neither infinite or NaN - #[inline(always)] + #[inline] fn is_finite(&self) -> bool { (*self as f64).is_finite() } /// Returns `true` if the number is neither zero, infinite, subnormal or NaN - #[inline(always)] + #[inline] fn is_normal(&self) -> bool { (*self as f64).is_normal() } /// Returns the floating point category of the number. If only one property is going to /// be tested, it is generally faster to use the specific predicate instead. - #[inline(always)] + #[inline] fn classify(&self) -> FPCategory { (*self as f64).classify() } - #[inline(always)] + #[inline] fn mantissa_digits() -> uint { Float::mantissa_digits::<f64>() } - #[inline(always)] + #[inline] fn digits() -> uint { Float::digits::<f64>() } - #[inline(always)] + #[inline] fn epsilon() -> float { Float::epsilon::<f64>() as float } - #[inline(always)] + #[inline] fn min_exp() -> int { Float::min_exp::<f64>() } - #[inline(always)] + #[inline] fn max_exp() -> int { Float::max_exp::<f64>() } - #[inline(always)] + #[inline] fn min_10_exp() -> int { Float::min_10_exp::<f64>() } - #[inline(always)] + #[inline] fn max_10_exp() -> int { Float::max_10_exp::<f64>() } /// Constructs a floating point number by multiplying `x` by 2 raised to the power of `exp` - #[inline(always)] + #[inline] fn ldexp(x: float, exp: int) -> float { Float::ldexp(x as f64, exp) as float } @@ -906,7 +906,7 @@ impl Float for float { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` /// - #[inline(always)] + #[inline] fn frexp(&self) -> (float, int) { match (*self as f64).frexp() { (x, exp) => (x as float, exp) @@ -917,7 +917,7 @@ impl Float for float { /// Returns the exponential of the number, minus `1`, in a way that is accurate /// even if the number is close to zero /// - #[inline(always)] + #[inline] fn exp_m1(&self) -> float { (*self as f64).exp_m1() as float } @@ -926,7 +926,7 @@ impl Float for float { /// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately /// than if the operations were performed separately /// - #[inline(always)] + #[inline] fn ln_1p(&self) -> float { (*self as f64).ln_1p() as float } @@ -936,13 +936,13 @@ impl Float for float { /// produces a more accurate result with better performance than a separate multiplication /// operation followed by an add. /// - #[inline(always)] + #[inline] fn mul_add(&self, a: float, b: float) -> float { mul_add(*self as f64, a as f64, b as f64) as float } /// Returns the next representable floating-point value in the direction of `other` - #[inline(always)] + #[inline] fn next_after(&self, other: float) -> float { next_after(*self as f64, other as f64) as float } diff --git a/src/libstd/num/i16.rs b/src/libstd/num/i16.rs index 9977247b249..eec20297a53 100644 --- a/src/libstd/num/i16.rs +++ b/src/libstd/num/i16.rs @@ -19,14 +19,14 @@ int_module!(i16, 16) impl BitCount for i16 { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline] fn population_count(&self) -> i16 { unsafe { intrinsics::ctpop16(*self) } } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline] fn leading_zeros(&self) -> i16 { unsafe { intrinsics::ctlz16(*self) } } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline] fn trailing_zeros(&self) -> i16 { unsafe { intrinsics::cttz16(*self) } } } diff --git a/src/libstd/num/i32.rs b/src/libstd/num/i32.rs index 0115f306e4e..769187cc66d 100644 --- a/src/libstd/num/i32.rs +++ b/src/libstd/num/i32.rs @@ -19,14 +19,14 @@ int_module!(i32, 32) impl BitCount for i32 { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline] fn population_count(&self) -> i32 { unsafe { intrinsics::ctpop32(*self) } } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline] fn leading_zeros(&self) -> i32 { unsafe { intrinsics::ctlz32(*self) } } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline] fn trailing_zeros(&self) -> i32 { unsafe { intrinsics::cttz32(*self) } } } diff --git a/src/libstd/num/i64.rs b/src/libstd/num/i64.rs index 4e280f01f27..ae0e59d1661 100644 --- a/src/libstd/num/i64.rs +++ b/src/libstd/num/i64.rs @@ -19,14 +19,14 @@ int_module!(i64, 64) impl BitCount for i64 { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline] fn population_count(&self) -> i64 { unsafe { intrinsics::ctpop64(*self) } } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline] fn leading_zeros(&self) -> i64 { unsafe { intrinsics::ctlz64(*self) } } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline] fn trailing_zeros(&self) -> i64 { unsafe { intrinsics::cttz64(*self) } } } diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs index 939965b9691..31a1f4241f5 100644 --- a/src/libstd/num/i8.rs +++ b/src/libstd/num/i8.rs @@ -19,14 +19,14 @@ int_module!(i8, 8) impl BitCount for i8 { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline] fn population_count(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline] fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self) } } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline] fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self) } } } diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs index 96ef7e9e341..d3c2733b47d 100644 --- a/src/libstd/num/int.rs +++ b/src/libstd/num/int.rs @@ -22,30 +22,30 @@ int_module!(int, super::bits) #[cfg(target_word_size = "32")] impl BitCount for int { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline] fn population_count(&self) -> int { (*self as i32).population_count() as int } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline] fn leading_zeros(&self) -> int { (*self as i32).leading_zeros() as int } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline] fn trailing_zeros(&self) -> int { (*self as i32).trailing_zeros() as int } } #[cfg(target_word_size = "64")] impl BitCount for int { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline] fn population_count(&self) -> int { (*self as i64).population_count() as int } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline] fn leading_zeros(&self) -> int { (*self as i64).leading_zeros() as int } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline] fn trailing_zeros(&self) -> int { (*self as i64).trailing_zeros() as int } } diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 74f74d11b73..74ec46ccfcd 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -27,17 +27,17 @@ pub static min_value: $T = (-1 as $T) << (bits - 1); pub static max_value: $T = min_value - 1 as $T; /// Calculates the sum of two numbers -#[inline(always)] +#[inline] pub fn add(x: $T, y: $T) -> $T { x + y } /// Subtracts the second number from the first -#[inline(always)] +#[inline] pub fn sub(x: $T, y: $T) -> $T { x - y } /// Multiplies two numbers together -#[inline(always)] +#[inline] pub fn mul(x: $T, y: $T) -> $T { x * y } /// Divides the first argument by the second argument (using integer division) /// Divides the first argument by the second argument (using integer division) -#[inline(always)] +#[inline] pub fn div(x: $T, y: $T) -> $T { x / y } /// @@ -60,26 +60,26 @@ pub fn div(x: $T, y: $T) -> $T { x / y } /// ~~~ /// /// -#[inline(always)] +#[inline] pub fn rem(x: $T, y: $T) -> $T { x % y } /// Returns true iff `x < y` -#[inline(always)] +#[inline] pub fn lt(x: $T, y: $T) -> bool { x < y } /// Returns true iff `x <= y` -#[inline(always)] +#[inline] pub fn le(x: $T, y: $T) -> bool { x <= y } /// Returns true iff `x == y` -#[inline(always)] +#[inline] pub fn eq(x: $T, y: $T) -> bool { x == y } /// Returns true iff `x != y` -#[inline(always)] +#[inline] pub fn ne(x: $T, y: $T) -> bool { x != y } /// Returns true iff `x >= y` -#[inline(always)] +#[inline] pub fn ge(x: $T, y: $T) -> bool { x >= y } /// Returns true iff `x > y` -#[inline(always)] +#[inline] pub fn gt(x: $T, y: $T) -> bool { x > y } /// @@ -99,7 +99,7 @@ pub fn gt(x: $T, y: $T) -> bool { x > y } /// assert!(sum == 10); /// ~~~ /// -#[inline(always)] +#[inline] pub fn range_step(start: $T, stop: $T, step: $T, it: &fn($T) -> bool) -> bool { let mut i = start; if step == 0 { @@ -122,62 +122,62 @@ pub fn range_step(start: $T, stop: $T, step: $T, it: &fn($T) -> bool) -> bool { return true; } -#[inline(always)] +#[inline] /// Iterate over the range [`lo`..`hi`) pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool { range_step(lo, hi, 1 as $T, it) } -#[inline(always)] +#[inline] /// Iterate over the range [`hi`..`lo`) pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool { range_step(hi, lo, -1 as $T, it) } /// Computes the bitwise complement -#[inline(always)] +#[inline] pub fn compl(i: $T) -> $T { -1 as $T ^ i } /// Computes the absolute value -#[inline(always)] +#[inline] pub fn abs(i: $T) -> $T { i.abs() } impl Num for $T {} #[cfg(not(test))] impl Ord for $T { - #[inline(always)] + #[inline] fn lt(&self, other: &$T) -> bool { return (*self) < (*other); } - #[inline(always)] + #[inline] fn le(&self, other: &$T) -> bool { return (*self) <= (*other); } - #[inline(always)] + #[inline] fn ge(&self, other: &$T) -> bool { return (*self) >= (*other); } - #[inline(always)] + #[inline] fn gt(&self, other: &$T) -> bool { return (*self) > (*other); } } #[cfg(not(test))] impl Eq for $T { - #[inline(always)] + #[inline] fn eq(&self, other: &$T) -> bool { return (*self) == (*other); } - #[inline(always)] + #[inline] fn ne(&self, other: &$T) -> bool { return (*self) != (*other); } } impl Orderable for $T { - #[inline(always)] + #[inline] fn min(&self, other: &$T) -> $T { if *self < *other { *self } else { *other } } - #[inline(always)] + #[inline] fn max(&self, other: &$T) -> $T { if *self > *other { *self } else { *other } } - #[inline(always)] + #[inline] fn clamp(&self, mn: &$T, mx: &$T) -> $T { if *self > *mx { *mx } else if *self < *mn { *mn } else { *self } @@ -185,33 +185,33 @@ impl Orderable for $T { } impl Zero for $T { - #[inline(always)] + #[inline] fn zero() -> $T { 0 } - #[inline(always)] + #[inline] fn is_zero(&self) -> bool { *self == 0 } } impl One for $T { - #[inline(always)] + #[inline] fn one() -> $T { 1 } } #[cfg(not(test))] impl Add<$T,$T> for $T { - #[inline(always)] + #[inline] fn add(&self, other: &$T) -> $T { *self + *other } } #[cfg(not(test))] impl Sub<$T,$T> for $T { - #[inline(always)] + #[inline] fn sub(&self, other: &$T) -> $T { *self - *other } } #[cfg(not(test))] impl Mul<$T,$T> for $T { - #[inline(always)] + #[inline] fn mul(&self, other: &$T) -> $T { *self * *other } } @@ -235,7 +235,7 @@ impl Div<$T,$T> for $T { /// assert!(-1 / -2 == 0); /// ~~~ /// - #[inline(always)] + #[inline] fn div(&self, other: &$T) -> $T { *self / *other } } @@ -262,19 +262,19 @@ impl Rem<$T,$T> for $T { /// assert!(-1 % -2 == -1); /// ~~~ /// - #[inline(always)] + #[inline] fn rem(&self, other: &$T) -> $T { *self % *other } } #[cfg(not(test))] impl Neg<$T> for $T { - #[inline(always)] + #[inline] fn neg(&self) -> $T { -*self } } impl Signed for $T { /// Computes the absolute value - #[inline(always)] + #[inline] fn abs(&self) -> $T { if self.is_negative() { -*self } else { *self } } @@ -283,7 +283,7 @@ impl Signed for $T { /// The positive difference of two numbers. Returns `0` if the number is less than or /// equal to `other`, otherwise the difference between`self` and `other` is returned. /// - #[inline(always)] + #[inline] fn abs_sub(&self, other: &$T) -> $T { if *self <= *other { 0 } else { *self - *other } } @@ -295,7 +295,7 @@ impl Signed for $T { /// - `1` if the number is positive /// - `-1` if the number is negative /// - #[inline(always)] + #[inline] fn signum(&self) -> $T { match *self { n if n > 0 => 1, @@ -305,11 +305,11 @@ impl Signed for $T { } /// Returns true if the number is positive - #[inline(always)] + #[inline] fn is_positive(&self) -> bool { *self > 0 } /// Returns true if the number is negative - #[inline(always)] + #[inline] fn is_negative(&self) -> bool { *self < 0 } } @@ -331,7 +331,7 @@ impl Integer for $T { /// assert!((-1).div_floor(-2) == 0); /// ~~~ /// - #[inline(always)] + #[inline] fn div_floor(&self, other: &$T) -> $T { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) @@ -363,7 +363,7 @@ impl Integer for $T { /// assert!((-1).mod_floor(-2) == -1); /// ~~~ /// - #[inline(always)] + #[inline] fn mod_floor(&self, other: &$T) -> $T { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) @@ -375,7 +375,7 @@ impl Integer for $T { } /// Calculates `div_floor` and `mod_floor` simultaneously - #[inline(always)] + #[inline] fn div_mod_floor(&self, other: &$T) -> ($T,$T) { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) @@ -387,7 +387,7 @@ impl Integer for $T { } /// Calculates `div` (`\`) and `rem` (`%`) simultaneously - #[inline(always)] + #[inline] fn div_rem(&self, other: &$T) -> ($T,$T) { (*self / *other, *self % *other) } @@ -397,7 +397,7 @@ impl Integer for $T { /// /// The result is always positive /// - #[inline(always)] + #[inline] fn gcd(&self, other: &$T) -> $T { // Use Euclid's algorithm let mut (m, n) = (*self, *other); @@ -412,21 +412,21 @@ impl Integer for $T { /// /// Calculates the Lowest Common Multiple (LCM) of the number and `other` /// - #[inline(always)] + #[inline] fn lcm(&self, other: &$T) -> $T { ((*self * *other) / self.gcd(other)).abs() // should not have to recaluculate abs } /// Returns `true` if the number can be divided by `other` without leaving a remainder - #[inline(always)] + #[inline] fn is_multiple_of(&self, other: &$T) -> bool { *self % *other == 0 } /// Returns `true` if the number is divisible by `2` - #[inline(always)] + #[inline] fn is_even(&self) -> bool { self.is_multiple_of(&2) } /// Returns `true` if the number is not divisible by `2` - #[inline(always)] + #[inline] fn is_odd(&self) -> bool { !self.is_even() } } @@ -434,90 +434,90 @@ impl Bitwise for $T {} #[cfg(not(test))] impl BitOr<$T,$T> for $T { - #[inline(always)] + #[inline] fn bitor(&self, other: &$T) -> $T { *self | *other } } #[cfg(not(test))] impl BitAnd<$T,$T> for $T { - #[inline(always)] + #[inline] fn bitand(&self, other: &$T) -> $T { *self & *other } } #[cfg(not(test))] impl BitXor<$T,$T> for $T { - #[inline(always)] + #[inline] fn bitxor(&self, other: &$T) -> $T { *self ^ *other } } #[cfg(not(test))] impl Shl<$T,$T> for $T { - #[inline(always)] + #[inline] fn shl(&self, other: &$T) -> $T { *self << *other } } #[cfg(not(test))] impl Shr<$T,$T> for $T { - #[inline(always)] + #[inline] fn shr(&self, other: &$T) -> $T { *self >> *other } } #[cfg(not(test))] impl Not<$T> for $T { - #[inline(always)] + #[inline] fn not(&self) -> $T { !*self } } impl Bounded for $T { - #[inline(always)] + #[inline] fn min_value() -> $T { min_value } - #[inline(always)] + #[inline] fn max_value() -> $T { max_value } } impl Int for $T {} impl Primitive for $T { - #[inline(always)] + #[inline] fn bits() -> uint { bits } - #[inline(always)] + #[inline] fn bytes() -> uint { bits / 8 } } // String conversion functions and impl str -> num /// Parse a string as a number in base 10. -#[inline(always)] +#[inline] pub fn from_str(s: &str) -> Option<$T> { strconv::from_str_common(s, 10u, true, false, false, strconv::ExpNone, false, false) } /// Parse a string as a number in the given base. -#[inline(always)] +#[inline] pub fn from_str_radix(s: &str, radix: uint) -> Option<$T> { strconv::from_str_common(s, radix, true, false, false, strconv::ExpNone, false, false) } /// Parse a byte slice as a number in the given base. -#[inline(always)] +#[inline] pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> { strconv::from_str_bytes_common(buf, radix, true, false, false, strconv::ExpNone, false, false) } impl FromStr for $T { - #[inline(always)] + #[inline] fn from_str(s: &str) -> Option<$T> { from_str(s) } } impl FromStrRadix for $T { - #[inline(always)] + #[inline] fn from_str_radix(s: &str, radix: uint) -> Option<$T> { from_str_radix(s, radix) } @@ -526,7 +526,7 @@ impl FromStrRadix for $T { // String conversion functions and impl num -> str /// Convert to a string as a byte slice in a given base. -#[inline(always)] +#[inline] pub fn to_str_bytes<U>(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, strconv::SignNeg, strconv::DigAll); @@ -534,7 +534,7 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { } /// Convert to a string in base 10. -#[inline(always)] +#[inline] pub fn to_str(num: $T) -> ~str { let (buf, _) = strconv::to_str_common(&num, 10u, false, strconv::SignNeg, strconv::DigAll); @@ -542,7 +542,7 @@ pub fn to_str(num: $T) -> ~str { } /// Convert to a string in a given base. -#[inline(always)] +#[inline] pub fn to_str_radix(num: $T, radix: uint) -> ~str { let (buf, _) = strconv::to_str_common(&num, radix, false, strconv::SignNeg, strconv::DigAll); @@ -550,14 +550,14 @@ pub fn to_str_radix(num: $T, radix: uint) -> ~str { } impl ToStr for $T { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str(*self) } } impl ToStrRadix for $T { - #[inline(always)] + #[inline] fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } diff --git a/src/libstd/num/num.rs b/src/libstd/num/num.rs index e7315624368..30a18a0587b 100644 --- a/src/libstd/num/num.rs +++ b/src/libstd/num/num.rs @@ -307,7 +307,7 @@ pub trait Float: Real /// assert_eq!(twenty, 20f32); /// ~~~ /// -#[inline(always)] +#[inline] pub fn cast<T:NumCast,U:NumCast>(n: T) -> U { NumCast::from(n) } @@ -338,28 +338,28 @@ pub trait NumCast { macro_rules! impl_num_cast( ($T:ty, $conv:ident) => ( impl NumCast for $T { - #[inline(always)] + #[inline] fn from<N:NumCast>(n: N) -> $T { // `$conv` could be generated using `concat_idents!`, but that // macro seems to be broken at the moment n.$conv() } - #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - - #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] fn to_int(&self) -> int { *self as int } - - #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] fn to_float(&self) -> float { *self as float } + #[inline] fn to_u8(&self) -> u8 { *self as u8 } + #[inline] fn to_u16(&self) -> u16 { *self as u16 } + #[inline] fn to_u32(&self) -> u32 { *self as u32 } + #[inline] fn to_u64(&self) -> u64 { *self as u64 } + #[inline] fn to_uint(&self) -> uint { *self as uint } + + #[inline] fn to_i8(&self) -> i8 { *self as i8 } + #[inline] fn to_i16(&self) -> i16 { *self as i16 } + #[inline] fn to_i32(&self) -> i32 { *self as i32 } + #[inline] fn to_i64(&self) -> i64 { *self as i64 } + #[inline] fn to_int(&self) -> int { *self as int } + + #[inline] fn to_f32(&self) -> f32 { *self as f32 } + #[inline] fn to_f64(&self) -> f64 { *self as f64 } + #[inline] fn to_float(&self) -> float { *self as float } } ) ) diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 75c4fa98a2b..a062838aacf 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -42,12 +42,12 @@ pub enum SignFormat { SignAll } -#[inline(always)] +#[inline] fn is_NaN<T:Eq>(num: &T) -> bool { *num != *num } -#[inline(always)] +#[inline] fn is_inf<T:Eq+NumStrConv>(num: &T) -> bool { match NumStrConv::inf() { None => false, @@ -55,7 +55,7 @@ fn is_inf<T:Eq+NumStrConv>(num: &T) -> bool { } } -#[inline(always)] +#[inline] fn is_neg_inf<T:Eq+NumStrConv>(num: &T) -> bool { match NumStrConv::neg_inf() { None => false, @@ -63,7 +63,7 @@ fn is_neg_inf<T:Eq+NumStrConv>(num: &T) -> bool { } } -#[inline(always)] +#[inline] fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Div<T,T>>(num: &T) -> bool { let _0: T = Zero::zero(); let _1: T = One::one(); @@ -83,23 +83,23 @@ pub trait NumStrConv { macro_rules! impl_NumStrConv_Floating (($t:ty) => ( impl NumStrConv for $t { - #[inline(always)] + #[inline] fn NaN() -> Option<$t> { Some( 0.0 / 0.0) } - #[inline(always)] + #[inline] fn inf() -> Option<$t> { Some( 1.0 / 0.0) } - #[inline(always)] + #[inline] fn neg_inf() -> Option<$t> { Some(-1.0 / 0.0) } - #[inline(always)] + #[inline] fn neg_zero() -> Option<$t> { Some(-0.0 ) } - #[inline(always)] + #[inline] fn round_to_zero(&self) -> $t { ( if *self < 0.0 { f64::ceil(*self as f64) } else { f64::floor(*self as f64) } ) as $t } - #[inline(always)] + #[inline] fn fractional_part(&self) -> $t { *self - self.round_to_zero() } @@ -108,13 +108,13 @@ macro_rules! impl_NumStrConv_Floating (($t:ty) => ( macro_rules! impl_NumStrConv_Integer (($t:ty) => ( impl NumStrConv for $t { - #[inline(always)] fn NaN() -> Option<$t> { None } - #[inline(always)] fn inf() -> Option<$t> { None } - #[inline(always)] fn neg_inf() -> Option<$t> { None } - #[inline(always)] fn neg_zero() -> Option<$t> { None } + #[inline] fn NaN() -> Option<$t> { None } + #[inline] fn inf() -> Option<$t> { None } + #[inline] fn neg_inf() -> Option<$t> { None } + #[inline] fn neg_zero() -> Option<$t> { None } - #[inline(always)] fn round_to_zero(&self) -> $t { *self } - #[inline(always)] fn fractional_part(&self) -> $t { 0 } + #[inline] fn round_to_zero(&self) -> $t { *self } + #[inline] fn fractional_part(&self) -> $t { 0 } } )) @@ -381,7 +381,7 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+ * Converts a number to its string representation. This is a wrapper for * `to_str_bytes_common()`, for details see there. */ -#[inline(always)] +#[inline] pub fn to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+ Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>( num: &T, radix: uint, negative_zero: bool, @@ -632,7 +632,7 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+ * Parses a string as a number. This is a wrapper for * `from_str_bytes_common()`, for details see there. */ -#[inline(always)] +#[inline] pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+Mul<T,T>+ Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv>( buf: &str, radix: uint, negative: bool, fractional: bool, diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index bcb97ff5a07..126150c0f1b 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -95,7 +95,7 @@ pub fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool { } impl iter::Times for uint { - #[inline(always)] + #[inline] /// /// A convenience form for basic iteration. Given a uint `x`, /// `for x.times { ... }` executes the given block x times. @@ -117,7 +117,7 @@ impl iter::Times for uint { } /// Returns the smallest power of 2 greater than or equal to `n` -#[inline(always)] +#[inline] pub fn next_power_of_two(n: uint) -> uint { let halfbits: uint = sys::size_of::<uint>() * 4u; let mut tmp: uint = n - 1u; diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 2bc1ca9c673..52f620f97ce 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -28,42 +28,42 @@ pub static min_value: $T = 0 as $T; pub static max_value: $T = 0 as $T - 1 as $T; /// Calculates the sum of two numbers -#[inline(always)] +#[inline] pub fn add(x: $T, y: $T) -> $T { x + y } /// Subtracts the second number from the first -#[inline(always)] +#[inline] pub fn sub(x: $T, y: $T) -> $T { x - y } /// Multiplies two numbers together -#[inline(always)] +#[inline] pub fn mul(x: $T, y: $T) -> $T { x * y } /// Divides the first argument by the second argument (using integer division) -#[inline(always)] +#[inline] pub fn div(x: $T, y: $T) -> $T { x / y } /// Calculates the integer remainder when x is divided by y (equivalent to the /// '%' operator) -#[inline(always)] +#[inline] pub fn rem(x: $T, y: $T) -> $T { x % y } /// Returns true iff `x < y` -#[inline(always)] +#[inline] pub fn lt(x: $T, y: $T) -> bool { x < y } /// Returns true iff `x <= y` -#[inline(always)] +#[inline] pub fn le(x: $T, y: $T) -> bool { x <= y } /// Returns true iff `x == y` -#[inline(always)] +#[inline] pub fn eq(x: $T, y: $T) -> bool { x == y } /// Returns true iff `x != y` -#[inline(always)] +#[inline] pub fn ne(x: $T, y: $T) -> bool { x != y } /// Returns true iff `x >= y` -#[inline(always)] +#[inline] pub fn ge(x: $T, y: $T) -> bool { x >= y } /// Returns true iff `x > y` -#[inline(always)] +#[inline] pub fn gt(x: $T, y: $T) -> bool { x > y } -#[inline(always)] +#[inline] /** * Iterate through a range with a given step value. * @@ -99,20 +99,20 @@ pub fn range_step(start: $T, stop: $T, step: $T_SIGNED, it: &fn($T) -> bool) -> return true; } -#[inline(always)] +#[inline] /// Iterate over the range [`lo`..`hi`) pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool { range_step(lo, hi, 1 as $T_SIGNED, it) } -#[inline(always)] +#[inline] /// Iterate over the range [`hi`..`lo`) pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool { range_step(hi, lo, -1 as $T_SIGNED, it) } /// Computes the bitwise complement -#[inline(always)] +#[inline] pub fn compl(i: $T) -> $T { max_value ^ i } @@ -121,37 +121,37 @@ impl Num for $T {} #[cfg(not(test))] impl Ord for $T { - #[inline(always)] + #[inline] fn lt(&self, other: &$T) -> bool { (*self) < (*other) } - #[inline(always)] + #[inline] fn le(&self, other: &$T) -> bool { (*self) <= (*other) } - #[inline(always)] + #[inline] fn ge(&self, other: &$T) -> bool { (*self) >= (*other) } - #[inline(always)] + #[inline] fn gt(&self, other: &$T) -> bool { (*self) > (*other) } } #[cfg(not(test))] impl Eq for $T { - #[inline(always)] + #[inline] fn eq(&self, other: &$T) -> bool { return (*self) == (*other); } - #[inline(always)] + #[inline] fn ne(&self, other: &$T) -> bool { return (*self) != (*other); } } impl Orderable for $T { - #[inline(always)] + #[inline] fn min(&self, other: &$T) -> $T { if *self < *other { *self } else { *other } } - #[inline(always)] + #[inline] fn max(&self, other: &$T) -> $T { if *self > *other { *self } else { *other } } /// Returns the number constrained within the range `mn <= self <= mx`. - #[inline(always)] + #[inline] fn clamp(&self, mn: &$T, mx: &$T) -> $T { cond!( (*self > *mx) { *mx } @@ -162,51 +162,51 @@ impl Orderable for $T { } impl Zero for $T { - #[inline(always)] + #[inline] fn zero() -> $T { 0 } - #[inline(always)] + #[inline] fn is_zero(&self) -> bool { *self == 0 } } impl One for $T { - #[inline(always)] + #[inline] fn one() -> $T { 1 } } #[cfg(not(test))] impl Add<$T,$T> for $T { - #[inline(always)] + #[inline] fn add(&self, other: &$T) -> $T { *self + *other } } #[cfg(not(test))] impl Sub<$T,$T> for $T { - #[inline(always)] + #[inline] fn sub(&self, other: &$T) -> $T { *self - *other } } #[cfg(not(test))] impl Mul<$T,$T> for $T { - #[inline(always)] + #[inline] fn mul(&self, other: &$T) -> $T { *self * *other } } #[cfg(not(test))] impl Div<$T,$T> for $T { - #[inline(always)] + #[inline] fn div(&self, other: &$T) -> $T { *self / *other } } #[cfg(not(test))] impl Rem<$T,$T> for $T { - #[inline(always)] + #[inline] fn rem(&self, other: &$T) -> $T { *self % *other } } #[cfg(not(test))] impl Neg<$T> for $T { - #[inline(always)] + #[inline] fn neg(&self) -> $T { -*self } } @@ -214,27 +214,27 @@ impl Unsigned for $T {} impl Integer for $T { /// Calculates `div` (`\`) and `rem` (`%`) simultaneously - #[inline(always)] + #[inline] fn div_rem(&self, other: &$T) -> ($T,$T) { (*self / *other, *self % *other) } /// Unsigned integer division. Returns the same result as `div` (`/`). - #[inline(always)] + #[inline] fn div_floor(&self, other: &$T) -> $T { *self / *other } /// Unsigned integer modulo operation. Returns the same result as `rem` (`%`). - #[inline(always)] + #[inline] fn mod_floor(&self, other: &$T) -> $T { *self / *other } /// Calculates `div_floor` and `modulo_floor` simultaneously - #[inline(always)] + #[inline] fn div_mod_floor(&self, other: &$T) -> ($T,$T) { (*self / *other, *self % *other) } /// Calculates the Greatest Common Divisor (GCD) of the number and `other` - #[inline(always)] + #[inline] fn gcd(&self, other: &$T) -> $T { // Use Euclid's algorithm let mut (m, n) = (*self, *other); @@ -247,21 +247,21 @@ impl Integer for $T { } /// Calculates the Lowest Common Multiple (LCM) of the number and `other` - #[inline(always)] + #[inline] fn lcm(&self, other: &$T) -> $T { (*self * *other) / self.gcd(other) } /// Returns `true` if the number can be divided by `other` without leaving a remainder - #[inline(always)] + #[inline] fn is_multiple_of(&self, other: &$T) -> bool { *self % *other == 0 } /// Returns `true` if the number is divisible by `2` - #[inline(always)] + #[inline] fn is_even(&self) -> bool { self.is_multiple_of(&2) } /// Returns `true` if the number is not divisible by `2` - #[inline(always)] + #[inline] fn is_odd(&self) -> bool { !self.is_even() } } @@ -269,45 +269,45 @@ impl Bitwise for $T {} #[cfg(not(test))] impl BitOr<$T,$T> for $T { - #[inline(always)] + #[inline] fn bitor(&self, other: &$T) -> $T { *self | *other } } #[cfg(not(test))] impl BitAnd<$T,$T> for $T { - #[inline(always)] + #[inline] fn bitand(&self, other: &$T) -> $T { *self & *other } } #[cfg(not(test))] impl BitXor<$T,$T> for $T { - #[inline(always)] + #[inline] fn bitxor(&self, other: &$T) -> $T { *self ^ *other } } #[cfg(not(test))] impl Shl<$T,$T> for $T { - #[inline(always)] + #[inline] fn shl(&self, other: &$T) -> $T { *self << *other } } #[cfg(not(test))] impl Shr<$T,$T> for $T { - #[inline(always)] + #[inline] fn shr(&self, other: &$T) -> $T { *self >> *other } } #[cfg(not(test))] impl Not<$T> for $T { - #[inline(always)] + #[inline] fn not(&self) -> $T { !*self } } impl Bounded for $T { - #[inline(always)] + #[inline] fn min_value() -> $T { min_value } - #[inline(always)] + #[inline] fn max_value() -> $T { max_value } } @@ -316,35 +316,35 @@ impl Int for $T {} // String conversion functions and impl str -> num /// Parse a string as a number in base 10. -#[inline(always)] +#[inline] pub fn from_str(s: &str) -> Option<$T> { strconv::from_str_common(s, 10u, false, false, false, strconv::ExpNone, false, false) } /// Parse a string as a number in the given base. -#[inline(always)] +#[inline] pub fn from_str_radix(s: &str, radix: uint) -> Option<$T> { strconv::from_str_common(s, radix, false, false, false, strconv::ExpNone, false, false) } /// Parse a byte slice as a number in the given base. -#[inline(always)] +#[inline] pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> { strconv::from_str_bytes_common(buf, radix, false, false, false, strconv::ExpNone, false, false) } impl FromStr for $T { - #[inline(always)] + #[inline] fn from_str(s: &str) -> Option<$T> { from_str(s) } } impl FromStrRadix for $T { - #[inline(always)] + #[inline] fn from_str_radix(s: &str, radix: uint) -> Option<$T> { from_str_radix(s, radix) } @@ -353,7 +353,7 @@ impl FromStrRadix for $T { // String conversion functions and impl num -> str /// Convert to a string as a byte slice in a given base. -#[inline(always)] +#[inline] pub fn to_str_bytes<U>(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, strconv::SignNeg, strconv::DigAll); @@ -361,7 +361,7 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { } /// Convert to a string in base 10. -#[inline(always)] +#[inline] pub fn to_str(num: $T) -> ~str { let (buf, _) = strconv::to_str_common(&num, 10u, false, strconv::SignNeg, strconv::DigAll); @@ -369,7 +369,7 @@ pub fn to_str(num: $T) -> ~str { } /// Convert to a string in a given base. -#[inline(always)] +#[inline] pub fn to_str_radix(num: $T, radix: uint) -> ~str { let (buf, _) = strconv::to_str_common(&num, radix, false, strconv::SignNeg, strconv::DigAll); @@ -377,42 +377,42 @@ pub fn to_str_radix(num: $T, radix: uint) -> ~str { } impl ToStr for $T { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str(*self) } } impl ToStrRadix for $T { - #[inline(always)] + #[inline] fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } } impl Primitive for $T { - #[inline(always)] + #[inline] fn bits() -> uint { bits } - #[inline(always)] + #[inline] fn bytes() -> uint { bits / 8 } } impl BitCount for $T { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline] fn population_count(&self) -> $T { (*self as $T_SIGNED).population_count() as $T } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline] fn leading_zeros(&self) -> $T { (*self as $T_SIGNED).leading_zeros() as $T } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline] fn trailing_zeros(&self) -> $T { (*self as $T_SIGNED).trailing_zeros() as $T } |
