Skip to content

Commit

Permalink
traits::select: quickly filter out predicates from other traits
Browse files Browse the repository at this point in the history
this improves most pre-trans passes's performance by ~1%.
  • Loading branch information
arielb1 committed Apr 23, 2017
1 parent 23de823 commit eadb049
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librustc/traits/select.rs
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 eadb049

Please sign in to comment.