Skip to content

Commit ce32246

Browse files
author
Dave Herman
committed
simpler computation of uint_bits(), plus whitespace police
1 parent 9a539a5 commit ce32246

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/comp/util/bits.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,9 @@ import std._vec;
99

1010
state type t = rec(vec[mutable uint] storage, uint nbits);
1111

12-
// FIXME: we should bind std.max_int
13-
fn is32bit() -> bool {
14-
let uint n = 0xffffffffu;
15-
ret (n + 1u) == 0u;
16-
}
17-
12+
// FIXME: this should be a constant once they work
1813
fn uint_bits() -> uint {
19-
if (is32bit()) {
20-
ret 31u;
21-
} else {
22-
ret 63u;
23-
}
14+
ret 32u + ((1u << 32u) >> 27u) - 1u;
2415
}
2516

2617
// FIXME: this should be state
@@ -36,8 +27,6 @@ fn create(uint nbits, bool init) -> t {
3627
nbits = nbits);
3728
}
3829

39-
40-
4130
// FIXME: this should be state
4231
fn process(fn(uint, uint) -> uint op, t v0, t v1) -> bool {
4332
auto len = _vec.len[mutable uint](v1.storage);

0 commit comments

Comments
 (0)