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
+9 -1
View File
@@ -206,7 +206,13 @@ impl Lamport {
impl fmt::Debug for Lamport {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Lamport {{{}: {}}}", self.replica_id, self.value)
if *self == Self::MAX {
write!(f, "Lamport {{MAX}}")
} else if *self == Self::MIN {
write!(f, "Lamport {{MIN}}")
} else {
write!(f, "Lamport {{{}: {}}}", self.replica_id, self.value)
}
}
}
@@ -219,6 +225,8 @@ impl fmt::Debug for Global {
}
if timestamp.replica_id == LOCAL_BRANCH_REPLICA_ID {
write!(f, "<branch>: {}", timestamp.value)?;
} else if timestamp.replica_id == AGENT_REPLICA_ID {
write!(f, "<agent>: {}", timestamp.value)?;
} else {
write!(f, "{}: {}", timestamp.replica_id, timestamp.value)?;
}