Skip to content

Commit

Permalink
Auto merge of #41486 - arielb1:select-where, r=eddyb
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 23, 2017
2 parents 2bd4b5c + eadb049 commit 15ce540
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 15ce540

Please sign in to comment.