Skip to content

Commit 35f33c1

Browse files
committed
Remove unnecessary fallbacks
The `target_word_size` attribute is always available at compile time, so there is no need for a fallback.
1 parent 32df8ed commit 35f33c1

File tree

2 files changed

+0
-82
lines changed

2 files changed

+0
-82
lines changed

src/libcore/num/int-template/int.rs

-41
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ mod inst {
2727
#[inline(always)]
2828
fn bits() -> uint { 64 }
2929

30-
// fallback if we don't have access to the current word size
31-
#[cfg(not(target_word_size = "32"),
32-
not(target_word_size = "64"))]
33-
#[inline(always)]
34-
fn bits() -> uint { ::sys::size_of::<int>() * 8 }
35-
3630
#[inline(always)]
3731
fn bytes() -> uint { Primitive::bits::<int>() / 8 }
3832
}
@@ -69,41 +63,6 @@ mod inst {
6963
fn trailing_zeros(&self) -> int { (*self as i32).trailing_zeros() as int }
7064
}
7165

72-
// fallback if we don't have access to the current word size
73-
#[cfg(not(target_word_size = "32"),
74-
not(target_word_size = "64"))]
75-
impl BitCount for int {
76-
/// Counts the number of bits set.
77-
#[inline(always)]
78-
fn population_count(&self) -> int {
79-
match ::sys::size_of::<int>() {
80-
8 => (*self as i64).population_count() as int,
81-
4 => (*self as i32).population_count() as int,
82-
s => fail!(fmt!("unsupported word size: %?", s)),
83-
}
84-
}
85-
86-
/// Counts the number of leading zeros.
87-
#[inline(always)]
88-
fn leading_zeros(&self) -> int {
89-
match ::sys::size_of::<int>() {
90-
8 => (*self as i64).leading_zeros() as int,
91-
4 => (*self as i32).leading_zeros() as int,
92-
s => fail!(fmt!("unsupported word size: %?", s)),
93-
}
94-
}
95-
96-
/// Counts the number of trailing zeros.
97-
#[inline(always)]
98-
fn trailing_zeros(&self) -> int {
99-
match ::sys::size_of::<int>() {
100-
8 => (*self as i64).trailing_zeros() as int,
101-
4 => (*self as i32).trailing_zeros() as int,
102-
s => fail!(fmt!("unsupported word size: %?", s)),
103-
}
104-
}
105-
}
106-
10766
/// Returns `base` raised to the power of `exponent`
10867
pub fn pow(base: int, exponent: uint) -> int {
10968
if exponent == 0u {

src/libcore/num/uint-template/uint.rs

-41
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ pub mod inst {
4141
#[inline(always)]
4242
fn bits() -> uint { 64 }
4343

44-
// fallback if we don't have access to the current word size
45-
#[cfg(not(target_word_size = "32"),
46-
not(target_word_size = "64"))]
47-
#[inline(always)]
48-
fn bits() -> uint { sys::size_of::<uint>() * 8 }
49-
5044
#[inline(always)]
5145
fn bytes() -> uint { Primitive::bits::<uint>() / 8 }
5246
}
@@ -83,41 +77,6 @@ pub mod inst {
8377
fn trailing_zeros(&self) -> uint { (*self as i32).trailing_zeros() as uint }
8478
}
8579

86-
// fallback if we don't have access to the current word size
87-
#[cfg(not(target_word_size = "32"),
88-
not(target_word_size = "64"))]
89-
impl BitCount for uint {
90-
/// Counts the number of bits set.
91-
#[inline(always)]
92-
fn population_count(&self) -> uint {
93-
match sys::size_of::<uint>() {
94-
8 => (*self as i64).population_count() as uint,
95-
4 => (*self as i32).population_count() as uint,
96-
s => fail!(fmt!("unsupported word size: %?", s)),
97-
}
98-
}
99-
100-
/// Counts the number of leading zeros.
101-
#[inline(always)]
102-
fn leading_zeros(&self) -> uint {
103-
match sys::size_of::<uint>() {
104-
8 => (*self as i64).leading_zeros() as uint,
105-
4 => (*self as i32).leading_zeros() as uint,
106-
s => fail!(fmt!("unsupported word size: %?", s)),
107-
}
108-
}
109-
110-
/// Counts the number of trailing zeros.
111-
#[inline(always)]
112-
fn trailing_zeros(&self) -> uint {
113-
match sys::size_of::<uint>() {
114-
8 => (*self as i64).trailing_zeros() as uint,
115-
4 => (*self as i32).trailing_zeros() as uint,
116-
s => fail!(fmt!("unsupported word size: %?", s)),
117-
}
118-
}
119-
}
120-
12180
///
12281
/// Divide two numbers, return the result, rounded up.
12382
///

0 commit comments

Comments
 (0)