Merge pull request #10971 from nilsocket/codeReformat

raft : write compact if statements
release-3.5
Xiang Li 2019-08-23 09:10:26 +08:00 committed by GitHub
commit f4dfd1976d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -55,10 +55,7 @@ func (u *unstable) maybeLastIndex() (uint64, bool) {
// is any.
func (u *unstable) maybeTerm(i uint64) (uint64, bool) {
if i < u.offset {
if u.snapshot == nil {
return 0, false
}
if u.snapshot.Metadata.Index == i {
if u.snapshot != nil && u.snapshot.Metadata.Index == i {
return u.snapshot.Metadata.Term, true
}
return 0, false
@ -71,6 +68,7 @@ func (u *unstable) maybeTerm(i uint64) (uint64, bool) {
if i > last {
return 0, false
}
return u.entries[i-u.offset].Term, true
}