Skip to content

Commit 2a3a544

Browse files
committed
Replace flat_map() with filter_map() in is_useful_specialized().
`filter_map()` is less general, but more efficient, and has the same effect in this case. This commit reduces the instruction count for `unicode_normalization-check-clean` by about 2%.
1 parent 5515a97 commit 2a3a544

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/librustc_mir/hair/pattern/_match.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1355,9 +1355,11 @@ fn is_useful_specialized<'p, 'a, 'tcx>(
13551355
}
13561356
}).collect();
13571357
let wild_patterns: Vec<_> = wild_patterns_owned.iter().collect();
1358-
let matrix = Matrix(m.iter().flat_map(|r| {
1359-
specialize(cx, &r, &ctor, &wild_patterns)
1360-
}).collect());
1358+
let matrix = Matrix(
1359+
m.iter()
1360+
.filter_map(|r| specialize(cx, &r, &ctor, &wild_patterns))
1361+
.collect()
1362+
);
13611363
match specialize(cx, v, &ctor, &wild_patterns) {
13621364
Some(v) => match is_useful(cx, &matrix, &v, witness) {
13631365
UsefulWithWitness(witnesses) => UsefulWithWitness(

0 commit comments

Comments
 (0)