Skip to content

Commit

Permalink
fixup! don't zero the zeroes
Browse files Browse the repository at this point in the history
  • Loading branch information
tbg committed Jun 19, 2019
1 parent a08826c commit 57def66
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions raft/quorum/majority.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,16 @@ func (c MajorityConfig) CommittedIndex(l AckedIndexer) Index {

{
// Fill the slice with the indexes observed. Any unused slots will be
// zeroed; these correspond to voters that may report in, but haven't
// yet. We fill from the right (since the zeroes will end up on the left
// after sorting below anyway).
// left as zero; these correspond to voters that may report in, but
// haven't yet. We fill from the right (since the zeroes will end up on
// the left after sorting below anyway).
i := n - 1
for id := range c {
if idx, ok := l.AckedIndex(id); ok {
srt[i] = uint64(idx)
i--
}
}
for j := 0; j <= i; j++ {
srt[j] = 0
}
}

// Sort by index. Use a bespoke algorithm (copied from the stdlib's sort
Expand Down

0 comments on commit 57def66

Please sign in to comment.