Skip to content

Commit 2954a19

Browse files
committed
---
yaml --- r: 2715 b: refs/heads/master c: 6432599 h: refs/heads/master i: 2713: 45a955b 2711: 50a84b9 v: v3
1 parent 4099d08 commit 2954a19

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 90e6453f46892f20235750dcc0bb95bbb1792380
2+
refs/heads/master: 6432599c5d7f2646c0f91c6badef5496f2fbc119

trunk/src/lib/bitv.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ fn uint_bits() -> uint {
3232
}
3333

3434
fn create(uint nbits, bool init) -> t {
35-
auto elt;
36-
if (init) {
37-
elt = ~0u;
35+
auto elt = if (init) {
36+
~0u
3837
} else {
39-
elt = 0u;
40-
}
38+
0u
39+
};
4140

4241
auto storage = vec::init_elt_mut[uint](elt, nbits / uint_bits() + 1u);
4342
ret rec(storage = storage, nbits = nbits);
@@ -161,11 +160,11 @@ fn set(&t v, uint i, bool x) {
161160
auto b = i % bits;
162161
auto w0 = v.storage.(w);
163162
auto flag = 1u << b;
164-
if (x) {
165-
v.storage.(w) = v.storage.(w) | flag;
163+
v.storage.(w) = if (x) {
164+
v.storage.(w) | flag
166165
} else {
167-
v.storage.(w) = v.storage.(w) & ~flag;
168-
}
166+
v.storage.(w) & ~flag
167+
};
169168
}
170169

171170
/* true if all bits are 1 */
@@ -191,11 +190,11 @@ fn is_false(&t v) -> bool {
191190
}
192191

193192
fn init_to_vec(t v, uint i) -> uint {
194-
if (get(v, i)) {
195-
ret 1u;
193+
ret if (get(v, i)) {
194+
1u
196195
} else {
197-
ret 0u;
198-
}
196+
0u
197+
};
199198
}
200199

201200
fn to_vec(&t v) -> vec[uint] {

0 commit comments

Comments
 (0)