From 7fcaca6d187d4bf6099fa195c1262e95a1bd357c Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Mon, 24 Nov 2014 23:08:51 -0800 Subject: [PATCH] raft: simplify raftLog.lastIndex --- raft/log.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/raft/log.go b/raft/log.go index d633a5e67..2e66d48dc 100644 --- a/raft/log.go +++ b/raft/log.go @@ -158,14 +158,7 @@ func (l *raftLog) firstIndex() uint64 { } func (l *raftLog) lastIndex() uint64 { - if len(l.unstableEnts) > 0 { - return l.unstable + uint64(len(l.unstableEnts)) - 1 - } - index, err := l.storage.LastIndex() - if err != nil { - panic(err) // TODO(bdarnell) - } - return index + return l.unstable + uint64(len(l.unstableEnts)) - 1 } func (l *raftLog) commitTo(tocommit uint64) {