multi_buffer: Reduce RefCell::borrow_mut calls to the bare minimum (#40522)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-17 18:17:34 +00:00
committed by GitHub
parent 1fbe1e3512
commit 27dcdb5841
9 changed files with 283 additions and 295 deletions
+4 -2
View File
@@ -72,13 +72,15 @@ impl ConflictSetSnapshot {
(None, None) => None,
(None, Some(conflict)) => Some(conflict.range.start),
(Some(conflict), None) => Some(conflict.range.start),
(Some(first), Some(second)) => Some(first.range.start.min(&second.range.start, buffer)),
(Some(first), Some(second)) => {
Some(*first.range.start.min(&second.range.start, buffer))
}
};
let end = match (old_conflicts.last(), new_conflicts.last()) {
(None, None) => None,
(None, Some(conflict)) => Some(conflict.range.end),
(Some(first), None) => Some(first.range.end),
(Some(first), Some(second)) => Some(first.range.end.max(&second.range.end, buffer)),
(Some(first), Some(second)) => Some(*first.range.end.max(&second.range.end, buffer)),
};
ConflictSetUpdate {
buffer_range: start.zip(end).map(|(start, end)| start..end),