Skip to content

Commit

Permalink
Use min
Browse files Browse the repository at this point in the history
  • Loading branch information
suzaku authored and andreev-io committed Dec 20, 2021
1 parent e79dd88 commit 08dbd38
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions little_raft/src/replica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,7 @@ where
// Update local commit index to either the received commit index or the
// latest local log position, whichever is smaller.
if commit_index > self.commit_index && !self.log.is_empty() {
self.commit_index = if commit_index < self.log[self.log.len() - 1].index {
commit_index
} else {
self.log[self.log.len() - 1].index
}
self.commit_index = cmp::min(commit_index, self.log[self.log.len() - 1].index)
}
self.cluster.lock().unwrap().register_leader(Some(from_id));
self.cluster.lock().unwrap().send_message(
Expand Down

0 comments on commit 08dbd38

Please sign in to comment.