From c0636ab087927152ed9dfdb0f532429f1626f57f Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 21 Aug 2018 18:06:55 +1000 Subject: [PATCH] Avoid some Place clones. This is a 0.5% speedup on ripgrep. --- src/librustc_mir/borrow_check/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index ce0e76a636db2..9d5be714ac7bb 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)) {