We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef8021f commit ab3dccaCopy full SHA for ab3dcca
storage.go
@@ -263,10 +263,9 @@ func (ms *MemoryStorage) Compact(compactIndex uint64) error {
263
// NB: allocate a new slice instead of reusing the old ms.ents. Entries in
264
// ms.ents are immutable, and can be referenced from outside MemoryStorage
265
// through slices returned by ms.Entries().
266
- ents := make([]pb.Entry, 1, uint64(len(ms.ents))-i)
267
- ents[0].Index = ms.ents[i].Index
268
- ents[0].Term = ms.ents[i].Term
269
- ents = append(ents, ms.ents[i+1:]...)
+ remainingCount := len(ms.ents) - int(i)
+ ents := make([]pb.Entry, remainingCount)
+ copy(ents, ms.ents[i:])
270
ms.ents = ents
271
return nil
272
}
0 commit comments