mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft : Write compact if statements
This commit is contained in:
parent
fb6d870e89
commit
18a077d3d3
@ -55,10 +55,7 @@ func (u *unstable) maybeLastIndex() (uint64, bool) {
|
|||||||
// is any.
|
// is any.
|
||||||
func (u *unstable) maybeTerm(i uint64) (uint64, bool) {
|
func (u *unstable) maybeTerm(i uint64) (uint64, bool) {
|
||||||
if i < u.offset {
|
if i < u.offset {
|
||||||
if u.snapshot == nil {
|
if u.snapshot != nil && u.snapshot.Metadata.Index == i {
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
if u.snapshot.Metadata.Index == i {
|
|
||||||
return u.snapshot.Metadata.Term, true
|
return u.snapshot.Metadata.Term, true
|
||||||
}
|
}
|
||||||
return 0, false
|
return 0, false
|
||||||
@ -71,6 +68,7 @@ func (u *unstable) maybeTerm(i uint64) (uint64, bool) {
|
|||||||
if i > last {
|
if i > last {
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
|
||||||
return u.entries[i-u.offset].Term, true
|
return u.entries[i-u.offset].Term, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user