Skip to content

Commit f029e1f

Browse files
committed
Annotate FIXMEs in std::bitv, and remove a FIXME
Changed a while loop into a for loop in std::bitv::equal. Yay!
1 parent cfa09d3 commit f029e1f

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/libstd/bitv.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export eq_vec;
2020
// union, intersection, and difference. At that point, we could write
2121
// an optimizing version of this module that produces a different obj
2222
// for the case where nbits <= 32.
23+
// (Issue #2341)
2324

2425
#[doc = "The bitvector type"]
2526
type bitv = @{storage: [mut uint], nbits: uint};
@@ -104,24 +105,18 @@ pure fn get(v: bitv, i: uint) -> bool {
104105
}
105106

106107
// FIXME: This doesn't account for the actual size of the vectors,
107-
// so it could end up comparing garbage bits
108+
// so it could end up comparing garbage bits (#2342)
108109
#[doc = "
109110
Compares two bitvectors
110111
111112
Both bitvectors must be the same length. Returns `true` if both bitvectors
112113
contain identical elements.
113114
"]
114115
fn equal(v0: bitv, v1: bitv) -> bool {
115-
// FIXME: when we can break or return from inside an iterator loop,
116-
// we can eliminate this painful while-loop
117-
118116
let len = vec::len(v1.storage);
119-
let mut i = 0u;
120-
while i < len {
117+
for uint::iterate(0u, len) {|i|
121118
if v0.storage[i] != v1.storage[i] { ret false; }
122-
i = i + 1u;
123119
}
124-
ret true;
125120
}
126121

127122
#[doc = "Set all bits to 0"]

0 commit comments

Comments
 (0)