diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-10-04 16:22:13 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-10-04 17:04:00 +1000 |
| commit | 2a3a5447418cc8e7a8b36ae4c9bdf8798a20b873 (patch) | |
| tree | e2acf805add3575878ea91f09da43e23ab0dfe69 /src | |
| parent | 5515a976464e488949a6a7324ac41ecaf3246a19 (diff) | |
| download | rust-2a3a5447418cc8e7a8b36ae4c9bdf8798a20b873.tar.gz rust-2a3a5447418cc8e7a8b36ae4c9bdf8798a20b873.zip | |
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%.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/hair/pattern/_match.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index c4f59e649b3..3ea58052877 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -1355,9 +1355,11 @@ fn is_useful_specialized<'p, 'a, 'tcx>( } }).collect(); let wild_patterns: Vec<_> = wild_patterns_owned.iter().collect(); - let matrix = Matrix(m.iter().flat_map(|r| { - specialize(cx, &r, &ctor, &wild_patterns) - }).collect()); + let matrix = Matrix( + m.iter() + .filter_map(|r| specialize(cx, &r, &ctor, &wild_patterns)) + .collect() + ); match specialize(cx, v, &ctor, &wild_patterns) { Some(v) => match is_useful(cx, &matrix, &v, witness) { UsefulWithWitness(witnesses) => UsefulWithWitness( |
