Skip to content

Commit

Permalink
NRG: Tidy up applyCommit (#5347)
Browse files Browse the repository at this point in the history
This PR doesn't change any logical behaviour, it just removes
unnecessary `fpae` and `original` variables/steps.

Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
derekcollison committed Apr 24, 2024
2 parents 21885f0 + 6bacc65 commit 163f02c
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions server/raft.go
Expand Up @@ -2684,15 +2684,11 @@ func (n *raft) applyCommit(index uint64) error {
n.debug("Ignoring apply commit for %d, already processed", index)
return nil
}
original := n.commit
n.commit = index

if n.State() == Leader {
delete(n.acks, index)
}

var fpae bool

ae := n.pae[index]
if ae == nil {
var state StreamState
Expand All @@ -2710,15 +2706,14 @@ func (n *raft) applyCommit(index uint64) error {
// Reset and cancel any catchup.
n.resetWAL()
n.cancelCatchup()
} else {
n.commit = original
}
return errEntryLoadFailed
}
} else {
fpae = true
defer delete(n.pae, index)
}

n.commit = index
ae.buf = nil

var committed []*Entry
Expand Down Expand Up @@ -2793,9 +2788,6 @@ func (n *raft) applyCommit(index uint64) error {
committed = append(committed, e)
}
}
if fpae {
delete(n.pae, index)
}
// Pass to the upper layers if we have normal entries. It is
// entirely possible that 'committed' might be an empty slice here,
// which will happen if we've processed updates inline (like peer
Expand Down

0 comments on commit 163f02c

Please sign in to comment.