Auto merge of #41486 - arielb1:select-where, r=eddyb

traits::select: quickly filter out predicates from other traits

this improves most pre-trans passes's performance by ~1%.

That missed the spring cleaning PR because I wanted to ship it.

r? @eddyb
This commit is contained in:
bors 2017-04-23 23:06:50 +00:00
commit 15ce54096a
1 changed files with 6 additions and 1 deletions

View File

@ -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 =