Remove unnecessary fallbacks

The `target_word_size` attribute is always available at compile time, so there is no need for a fallback.
This commit is contained in:
Brendan Zabarauskas 2013-04-27 10:34:29 +10:00
parent 32df8ed877
commit 35f33c17f7
2 changed files with 0 additions and 82 deletions

View File

@ -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::<int>() * 8 }
#[inline(always)]
fn bytes() -> uint { Primitive::bits::<int>() / 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::<int>() {
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::<int>() {
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::<int>() {
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 {

View File

@ -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::<uint>() * 8 }
#[inline(always)]
fn bytes() -> uint { Primitive::bits::<uint>() / 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::<uint>() {
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::<uint>() {
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::<uint>() {
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.
///