Skip to content

Commit 0be1a0b

Browse files
committed
rustc: Simplify tritv::copy; shaves a couple of seconds off typestate.
1 parent 4b23ea5 commit 0be1a0b

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/comp/middle/tstate/tritv.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -186,24 +186,11 @@ fn tritv_set(uint i, &t v, trit t) -> bool {
186186
}
187187

188188
fn tritv_copy(&t target, &t source) -> bool {
189-
let uint i = 0u;
190189
assert (target.nbits == source.nbits);
191-
auto changed = false;
192-
auto oldunc;
193-
auto newunc;
194-
auto oldval;
195-
auto newval;
196-
while (i < target.nbits) {
197-
oldunc = bitv::get(target.uncertain, i);
198-
newunc = bitv::get(source.uncertain, i);
199-
oldval = bitv::get(target.val, i);
200-
newval = bitv::get(source.val, i);
201-
bitv::set(target.uncertain, i, newunc);
202-
changed = changed || (oldunc && !newunc);
203-
bitv::set(target.val, i, newval);
204-
changed = changed || (oldval && !newval);
205-
i += 1u;
206-
}
190+
auto changed = !bitv::equal(target.uncertain, source.uncertain) ||
191+
!bitv::equal(target.val, source.val);
192+
bitv::copy(target.uncertain, source.uncertain);
193+
bitv::copy(target.val, source.val);
207194
ret changed;
208195
}
209196

0 commit comments

Comments
 (0)