From 35f33c17f7d242bce031a9e648e6c3f31dd59ef6 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Sat, 27 Apr 2013 10:34:29 +1000 Subject: Remove unnecessary fallbacks The `target_word_size` attribute is always available at compile time, so there is no need for a fallback. --- src/libcore/num/int-template/int.rs | 41 ----------------------------------- src/libcore/num/uint-template/uint.rs | 41 ----------------------------------- 2 files changed, 82 deletions(-) (limited to 'src/libcore/num') diff --git a/src/libcore/num/int-template/int.rs b/src/libcore/num/int-template/int.rs index bfe8bd0bfe6..c04e2a2e70d 100644 --- a/src/libcore/num/int-template/int.rs +++ b/src/libcore/num/int-template/int.rs @@ -27,12 +27,6 @@ mod inst { #[inline(always)] fn bits() -> uint { 64 } - // fallback if we don't have access to the current word size - #[cfg(not(target_word_size = "32"), - not(target_word_size = "64"))] - #[inline(always)] - fn bits() -> uint { ::sys::size_of::() * 8 } - #[inline(always)] fn bytes() -> uint { Primitive::bits::() / 8 } } @@ -69,41 +63,6 @@ mod inst { fn trailing_zeros(&self) -> int { (*self as i32).trailing_zeros() as int } } - // fallback if we don't have access to the current word size - #[cfg(not(target_word_size = "32"), - not(target_word_size = "64"))] - impl BitCount for int { - /// Counts the number of bits set. - #[inline(always)] - fn population_count(&self) -> int { - match ::sys::size_of::() { - 8 => (*self as i64).population_count() as int, - 4 => (*self as i32).population_count() as int, - s => fail!(fmt!("unsupported word size: %?", s)), - } - } - - /// Counts the number of leading zeros. - #[inline(always)] - fn leading_zeros(&self) -> int { - match ::sys::size_of::() { - 8 => (*self as i64).leading_zeros() as int, - 4 => (*self as i32).leading_zeros() as int, - s => fail!(fmt!("unsupported word size: %?", s)), - } - } - - /// Counts the number of trailing zeros. - #[inline(always)] - fn trailing_zeros(&self) -> int { - match ::sys::size_of::() { - 8 => (*self as i64).trailing_zeros() as int, - 4 => (*self as i32).trailing_zeros() as int, - s => fail!(fmt!("unsupported word size: %?", s)), - } - } - } - /// Returns `base` raised to the power of `exponent` pub fn pow(base: int, exponent: uint) -> int { if exponent == 0u { diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index 9e10ed63968..d333b0b58e1 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -41,12 +41,6 @@ pub mod inst { #[inline(always)] fn bits() -> uint { 64 } - // fallback if we don't have access to the current word size - #[cfg(not(target_word_size = "32"), - not(target_word_size = "64"))] - #[inline(always)] - fn bits() -> uint { sys::size_of::() * 8 } - #[inline(always)] fn bytes() -> uint { Primitive::bits::() / 8 } } @@ -83,41 +77,6 @@ pub mod inst { fn trailing_zeros(&self) -> uint { (*self as i32).trailing_zeros() as uint } } - // fallback if we don't have access to the current word size - #[cfg(not(target_word_size = "32"), - not(target_word_size = "64"))] - impl BitCount for uint { - /// Counts the number of bits set. - #[inline(always)] - fn population_count(&self) -> uint { - match sys::size_of::() { - 8 => (*self as i64).population_count() as uint, - 4 => (*self as i32).population_count() as uint, - s => fail!(fmt!("unsupported word size: %?", s)), - } - } - - /// Counts the number of leading zeros. - #[inline(always)] - fn leading_zeros(&self) -> uint { - match sys::size_of::() { - 8 => (*self as i64).leading_zeros() as uint, - 4 => (*self as i32).leading_zeros() as uint, - s => fail!(fmt!("unsupported word size: %?", s)), - } - } - - /// Counts the number of trailing zeros. - #[inline(always)] - fn trailing_zeros(&self) -> uint { - match sys::size_of::() { - 8 => (*self as i64).trailing_zeros() as uint, - 4 => (*self as i32).trailing_zeros() as uint, - s => fail!(fmt!("unsupported word size: %?", s)), - } - } - } - /// /// Divide two numbers, return the result, rounded up. /// -- cgit 1.4.1-3-g733a5