raft: use max in log.slice

release-2.0
Xiang Li 2014-11-24 08:36:15 -08:00
parent 9ddd8ee539
commit bdbafe2cf3
1 changed files with 1 additions and 6 deletions

View File

@ -285,12 +285,7 @@ func (l *raftLog) slice(lo uint64, hi uint64) []pb.Entry {
ents = append(ents, storedEnts...)
}
if len(l.unstableEnts) > 0 && hi > l.unstable {
var firstUnstable uint64
if lo < l.unstable {
firstUnstable = l.unstable
} else {
firstUnstable = lo
}
firstUnstable := max(lo, l.unstable)
ents = append(ents, l.unstableEnts[firstUnstable-l.unstable:hi-l.unstable]...)
}
return ents