about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-08-21 22:09:35 +0800
committerkennytm <kennytm@gmail.com>2018-08-21 22:09:35 +0800
commite3887e6c8afbaafe0332e9776199bc89030e227b (patch)
tree46ab5d92fc1f865894dfa7e95e1c2e4a491cf896
parent0dd88c97975b2a2e4ea3e4a2bdc3670a9f40bd67 (diff)
parentc0636ab087927152ed9dfdb0f532429f1626f57f (diff)
Rollup merge of #53551 - nnethercote:access_place_error_reported, r=varkor
Avoid some Place clones.

This is a 0.5% speedup on ripgrep.
-rw-r--r--src/librustc_mir/borrow_check/mod.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs
index 82d3d31a52e..4390ca37182 100644
--- a/src/librustc_mir/borrow_check/mod.rs
+++ b/src/librustc_mir/borrow_check/mod.rs
@@ -1080,7 +1080,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
             }
         }
 
-        if self
+        // Check is_empty() first because it's the common case, and doing that
+        // way we avoid the clone() call.
+        if !self.access_place_error_reported.is_empty() &&
+           self
             .access_place_error_reported
             .contains(&(place_span.0.clone(), place_span.1))
         {