]> git.lizzy.rs Git - rust.git/commitdiff
Avoid calling `unroll_place()` in a common case.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 27 Aug 2018 06:40:42 +0000 (16:40 +1000)
committerNicholas Nethercote <nnethercote@mozilla.com>
Mon, 27 Aug 2018 08:46:36 +0000 (18:46 +1000)
This reduces the execution time for `ucd-check` by 25%.

src/librustc_mir/borrow_check/places_conflict.rs

index f791735690922aaf81404a684cad5c3b88e9b7a4..3f055283e0c3f71a7389cc928a8c4c98034d1254 100644 (file)
@@ -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)