Skip to content

Commit cad425c

Browse files
committed
---
yaml --- r: 97845 b: refs/heads/snap-stage3 c: 3830a3b h: refs/heads/master i: 97843: 7c8e4b6 v: v3
1 parent 7ddb7d8 commit cad425c

File tree

4 files changed

+9
-45
lines changed

4 files changed

+9
-45
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: aaf8ba7c51011570e7a6bb350345c23378c4152c
4+
refs/heads/snap-stage3: 3830a3b4f2559165a89847320d277ef827dd1da9
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ impl<T : Iterator<char>> Parser<T> {
688688
}
689689
}
690690

691-
let exp: f64 = num::pow_with_uint(10u, exp);
691+
let exp: f64 = num::pow(10u as f64, exp);
692692
if neg_exp {
693693
res /= exp;
694694
} else {

branches/snap-stage3/src/libstd/num/mod.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -993,37 +993,6 @@ pub fn from_str_radix<T: FromStrRadix>(str: &str, radix: uint) -> Option<T> {
993993
FromStrRadix::from_str_radix(str, radix)
994994
}
995995

996-
/// Calculates a power to a given radix, optimized for uint `pow` and `radix`.
997-
///
998-
/// Returns `radix^pow` as `T`.
999-
///
1000-
/// Note:
1001-
/// Also returns `1` for `0^0`, despite that technically being an
1002-
/// undefined number. The reason for this is twofold:
1003-
/// - If code written to use this function cares about that special case, it's
1004-
/// probably going to catch it before making the call.
1005-
/// - If code written to use this function doesn't care about it, it's
1006-
/// probably assuming that `x^0` always equals `1`.
1007-
///
1008-
pub fn pow_with_uint<T:NumCast+One+Zero+Div<T,T>+Mul<T,T>>(radix: uint, pow: uint) -> T {
1009-
let _0: T = Zero::zero();
1010-
let _1: T = One::one();
1011-
1012-
if pow == 0u { return _1; }
1013-
if radix == 0u { return _0; }
1014-
let mut my_pow = pow;
1015-
let mut total = _1;
1016-
let mut multiplier = cast(radix).unwrap();
1017-
while (my_pow > 0u) {
1018-
if my_pow % 2u == 1u {
1019-
total = total * multiplier;
1020-
}
1021-
my_pow = my_pow / 2u;
1022-
multiplier = multiplier * multiplier;
1023-
}
1024-
total
1025-
}
1026-
1027996
impl<T: Zero + 'static> Zero for @T {
1028997
fn zero() -> @T { @Zero::zero() }
1029998
fn is_zero(&self) -> bool { (**self).is_zero() }
@@ -1698,10 +1667,4 @@ mod bench {
16981667
let v = vec::from_fn(1024, |n| n);
16991668
b.iter(|| {v.iter().fold(0, |old, new| num::pow(old, *new));});
17001669
}
1701-
1702-
#[bench]
1703-
fn bench_pow_with_uint_function(b: &mut BenchHarness) {
1704-
let v = vec::from_fn(1024, |n| n);
1705-
b.iter(|| {v.iter().fold(0, |old, new| num::pow_with_uint(old, *new));});
1706-
}
17071670
}

branches/snap-stage3/src/libstd/num/strconv.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use str::{StrSlice};
2020
use str;
2121
use vec::{CopyableVector, ImmutableVector, MutableVector};
2222
use vec::OwnedVector;
23-
use num::{NumCast, Zero, One, cast, pow_with_uint, Integer};
23+
use num;
24+
use num::{NumCast, Zero, One, cast, Integer};
2425
use num::{Round, Float, FPNaN, FPInfinite, ToPrimitive};
2526

2627
pub enum ExponentFormat {
@@ -648,10 +649,10 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
648649

649650
if exp_found {
650651
let c = buf[i] as char;
651-
let base = match (c, exponent) {
652+
let base: T = match (c, exponent) {
652653
// c is never _ so don't need to handle specially
653-
('e', ExpDec) | ('E', ExpDec) => 10u,
654-
('p', ExpBin) | ('P', ExpBin) => 2u,
654+
('e', ExpDec) | ('E', ExpDec) => cast(10u).unwrap(),
655+
('p', ExpBin) | ('P', ExpBin) => cast(2u).unwrap(),
655656
_ => return None // char doesn't fit given exponent format
656657
};
657658

@@ -664,9 +665,9 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
664665
match exp {
665666
Some(exp_pow) => {
666667
multiplier = if exp_pow < 0 {
667-
_1 / pow_with_uint::<T>(base, (-exp_pow.to_int().unwrap()) as uint)
668+
_1 / num::pow(base, (-exp_pow.to_int().unwrap()) as uint)
668669
} else {
669-
pow_with_uint::<T>(base, exp_pow.to_int().unwrap() as uint)
670+
num::pow(base, exp_pow.to_int().unwrap() as uint)
670671
}
671672
}
672673
None => return None // invalid exponent -> invalid number

0 commit comments

Comments
 (0)