about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-08-30 08:20:20 +0000
committerbors <bors@rust-lang.org>2018-08-30 08:20:20 +0000
commit03fe4c79f7cb4b2879277ef8ec123091c4414c6b (patch)
treefd32602c184b3f604e60b71ce3fa5026177eb7da
parentf1a5373a1b6222cf510d410f37278012b096fbfb (diff)
parent130e55665f8c9f078dec67a3e92467853f400250 (diff)
downloadrust-03fe4c79f7cb4b2879277ef8ec123091c4414c6b.tar.gz
rust-03fe4c79f7cb4b2879277ef8ec123091c4414c6b.zip
Auto merge of #53733 - nnethercote:avoid-unroll_place, r=nikomatsakis
Avoid calling `unroll_place()` in a common case.

This reduces the execution time for `ucd-check` by 25%.

r? @nikomatsakis
-rw-r--r--src/librustc_mir/borrow_check/places_conflict.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs
index f7917356909..3f055283e0c 100644
--- a/src/librustc_mir/borrow_check/places_conflict.rs
+++ b/src/librustc_mir/borrow_check/places_conflict.rs
@@ -29,6 +29,14 @@ pub(super) fn places_conflict<'gcx, 'tcx>(
         borrow_place, access_place, access
     );
 
+    // This Local/Local case is handled by the more general code below, but
+    // it's so common that it's a speed win to check for it first.
+    if let Place::Local(l1) = borrow_place {
+        if let Place::Local(l2) = access_place {
+            return l1 == l2;
+        }
+    }
+
     unroll_place(borrow_place, None, |borrow_components| {
         unroll_place(access_place, None, |access_components| {
             place_components_conflict(tcx, mir, borrow_components, access_components, access)