]> git.lizzy.rs Git - rust.git/commitdiff
don't iterate over all impls when none match
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Mon, 17 Aug 2015 21:17:02 +0000 (00:17 +0300)
committerAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Mon, 17 Aug 2015 21:25:29 +0000 (00:25 +0300)
before:
573.01user 4.04system 7:33.86elapsed 127%CPU (0avgtext+0avgdata 1141656maxresident)k
after:
567.03user 4.00system 7:28.23elapsed 127%CPU (0avgtext+0avgdata 1133112maxresident)k

an additional 1% improvement

src/librustc/middle/ty.rs

index f99760b6210c5b9774e9eada4618374ba22d1862..69b83b24ffd2179fcfacb30e630f876bee9aa478 100644 (file)
@@ -3222,13 +3222,12 @@ pub fn for_each_relevant_impl<F: FnMut(DefId)>(&self,
                 for &impl_def_id in impls {
                     f(impl_def_id);
                 }
-                return; // we don't need to process the other non-blanket impls
             }
-        }
-
-        for v in self.nonblanket_impls.borrow().values() {
-            for &impl_def_id in v {
-                f(impl_def_id);
+        } else {
+            for v in self.nonblanket_impls.borrow().values() {
+                for &impl_def_id in v {
+                    f(impl_def_id);
+                }
             }
         }
     }