Skip to content

Commit 130e556

Browse files
committed
Avoid calling unroll_place() in a common case.
This reduces the execution time for `ucd-check` by 25%.
1 parent 3a2c603 commit 130e556

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: src/librustc_mir/borrow_check/places_conflict.rs

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ pub(super) fn places_conflict<'gcx, 'tcx>(
2929
borrow_place, access_place, access
3030
);
3131

32+
// This Local/Local case is handled by the more general code below, but
33+
// it's so common that it's a speed win to check for it first.
34+
if let Place::Local(l1) = borrow_place {
35+
if let Place::Local(l2) = access_place {
36+
return l1 == l2;
37+
}
38+
}
39+
3240
unroll_place(borrow_place, None, |borrow_components| {
3341
unroll_place(access_place, None, |access_components| {
3442
place_components_conflict(tcx, mir, borrow_components, access_components, access)

0 commit comments

Comments
 (0)