about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2017-04-23 23:05:25 +0300
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2017-04-23 23:05:25 +0300
commiteadb049799162fc5265f404bd4c6671d223e5dd2 (patch)
tree3b909ad03d8aaaf517a1e7bc7331321b21a8a607
parent23de823e93dc19ef1b9cb65b48860a892cd6ff18 (diff)
downloadrust-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.rs7
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 =