raft: simplify the code in progress.go (#12119)

release-3.5
Binacs 2020-07-20 15:13:05 +08:00 committed by GitHub
parent da78fb5544
commit 89da79188f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 6 deletions

View File

@ -148,9 +148,7 @@ func (pr *Progress) MaybeUpdate(n uint64) bool {
updated = true
pr.ProbeAcked()
}
if pr.Next < n+1 {
pr.Next = n + 1
}
pr.Next = max(pr.Next, n+1)
return updated
}
@ -189,9 +187,7 @@ func (pr *Progress) MaybeDecrTo(rejected, last uint64) bool {
return false
}
if pr.Next = min(rejected, last+1); pr.Next < 1 {
pr.Next = 1
}
pr.Next = max(min(rejected, last+1), 1)
pr.ProbeSent = false
return true
}