Skip to content

Commit 6362c3a

Browse files
committed
Switch to using .enumerate() some places in _match.
1 parent 74efdf6 commit 6362c3a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/librustc/middle/trans/_match.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -1075,13 +1075,13 @@ fn pick_col(m: &[Match]) -> uint {
10751075
}
10761076
let mut scores = vec::from_elem(m[0].pats.len(), 0u);
10771077
for br in m.iter() {
1078-
let mut i = 0u;
1079-
for p in br.pats.iter() { scores[i] += score(*p); i += 1u; }
1078+
for (i, p) in br.pats.iter().enumerate() {
1079+
scores[i] += score(*p);
1080+
}
10801081
}
10811082
let mut max_score = 0u;
10821083
let mut best_col = 0u;
1083-
let mut i = 0u;
1084-
for score in scores.iter() {
1084+
for (i, score) in scores.iter().enumerate() {
10851085
let score = *score;
10861086

10871087
// Irrefutable columns always go first, they'd only be duplicated in
@@ -1090,7 +1090,6 @@ fn pick_col(m: &[Match]) -> uint {
10901090
// If no irrefutable ones are found, we pick the one with the biggest
10911091
// branching factor.
10921092
if score > max_score { max_score = score; best_col = i; }
1093-
i += 1u;
10941093
}
10951094
return best_col;
10961095
}
@@ -1490,13 +1489,11 @@ fn compile_submatch_continue(mut bcx: @mut Block,
14901489
let defaults = enter_default(else_cx, dm, m, col, val);
14911490
let exhaustive = chk.is_none() && defaults.len() == 0u;
14921491
let len = opts.len();
1493-
let mut i = 0u;
14941492

14951493
// Compile subtrees for each option
1496-
for opt in opts.iter() {
1497-
i += 1u;
1494+
for (i, opt) in opts.iter().enumerate() {
14981495
let mut opt_cx = else_cx;
1499-
if !exhaustive || i < len {
1496+
if !exhaustive || i+1 < len {
15001497
opt_cx = sub_block(bcx, "match_case");
15011498
match kind {
15021499
single => Br(bcx, opt_cx.llbb),

0 commit comments

Comments
 (0)