Explorar o código

raft: do not need to copy committed entries

Xiang Li %!s(int64=11) %!d(string=hai) anos
pai
achega
eaffaacf5e
Modificáronse 1 ficheiros con 1 adicións e 7 borrados
  1. 1 7
      raft/log.go

+ 1 - 7
raft/log.go

@@ -94,13 +94,7 @@ func (l *raftLog) resetUnstable() {
 // all the returned entries will be marked as applied.
 func (l *raftLog) nextEnts() (ents []pb.Entry) {
 	if l.committed > l.applied {
-		ents := l.slice(l.applied+1, l.committed+1)
-		if ents == nil {
-			return nil
-		}
-		cpy := make([]pb.Entry, len(ents))
-		copy(cpy, ents)
-		return cpy
+		return l.slice(l.applied+1, l.committed+1)
 	}
 	return nil
 }