diff options
| author | Matthijs Hofstra <thiezz@gmail.com> | 2013-05-29 20:21:04 +0200 |
|---|---|---|
| committer | Matthijs Hofstra <thiezz@gmail.com> | 2013-05-29 20:21:04 +0200 |
| commit | 3141acf674fd34f66141c4659a4a239779bb2802 (patch) | |
| tree | c1a5945abac327b84b6cf5f5ef30187f5bda565c /src/libstd | |
| parent | 6cc9a26a2d61acc0b1d707104f8c2a8b7c990012 (diff) | |
| download | rust-3141acf674fd34f66141c4659a4a239779bb2802.tar.gz rust-3141acf674fd34f66141c4659a4a239779bb2802.zip | |
Changed to a more efficient implementation.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/num/f32.rs | 10 | ||||
| -rw-r--r-- | src/libstd/num/f64.rs | 10 |
2 files changed, 4 insertions, 16 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 0d166c8887c..b578084268a 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -147,18 +147,12 @@ pub fn gt(x: f32, y: f32) -> bool { return x > y; } #[inline(always)] pub fn fmax(x: f32, y: f32) -> f32 { - if x.is_NaN() { y } - else if y.is_NaN() { x } - else if x > y { x } - else { y } + if x >= y || y.is_NaN() { x } else { y } } #[inline(always)] pub fn fmin(x: f32, y: f32) -> f32 { - if x.is_NaN() { y } - else if y.is_NaN() { x } - else if x < y { x } - else { y } + if x <= y || y.is_NaN() { x } else { y } } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 910e2e1e692..bca730c5748 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -172,18 +172,12 @@ pub fn gt(x: f64, y: f64) -> bool { return x > y; } #[inline(always)] pub fn fmax(x: f64, y: f64) -> f64 { - if x.is_NaN() { y } - else if y.is_NaN() { x } - else if x > y { x } - else { y } + if x >= y || y.is_NaN() { x } else { y } } #[inline(always)] pub fn fmin(x: f64, y: f64) -> f64 { - if x.is_NaN() { y } - else if y.is_NaN() { x } - else if x < y { x } - else { y } + if x <= y || y.is_NaN() { x } else { y } } // FIXME (#1999): add is_normal, is_subnormal, and fpclassify |
