diff options
| author | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2017-04-23 23:05:25 +0300 |
|---|---|---|
| committer | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2017-04-23 23:05:25 +0300 |
| commit | eadb049799162fc5265f404bd4c6671d223e5dd2 (patch) | |
| tree | 3b909ad03d8aaaf517a1e7bc7331321b21a8a607 | |
| parent | 23de823e93dc19ef1b9cb65b48860a892cd6ff18 (diff) | |
| download | rust-eadb049799162fc5265f404bd4c6671d223e5dd2.tar.gz rust-eadb049799162fc5265f404bd4c6671d223e5dd2.zip | |
traits::select: quickly filter out predicates from other traits
this improves most pre-trans passes's performance by ~1%.
| -rw-r--r-- | src/librustc/traits/select.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 6442487ead9..6dbf861d278 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -1300,8 +1300,13 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { .iter() .filter_map(|o| o.to_opt_poly_trait_ref()); + // micro-optimization: filter out predicates relating to different + // traits. let matching_bounds = - all_bounds.filter( + all_bounds.filter(|p| p.def_id() == stack.obligation.predicate.def_id()); + + let matching_bounds = + matching_bounds.filter( |bound| self.evaluate_where_clause(stack, bound.clone()).may_apply()); let param_candidates = |
