Check nil err first when committing (#12625)

The most common case is to have a nil error when appending series, so
let's check that first instead of checking the 3 error types first.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
This commit is contained in:
Oleg Zaytsev 2023-08-01 14:04:45 +02:00 committed by GitHub
parent f26dfc95e6
commit cd7d0b69a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -930,6 +930,8 @@ func (a *headAppender) Commit() (err error) {
oooSample, _, err := series.appendable(s.T, s.V, a.headMaxt, a.minValidTime, a.oooTimeWindow)
switch err {
case nil:
// Do nothing.
case storage.ErrOutOfOrderSample:
samplesAppended--
oooRejected++
@ -939,8 +941,6 @@ func (a *headAppender) Commit() (err error) {
case storage.ErrTooOldSample:
samplesAppended--
tooOldRejected++
case nil:
// Do nothing.
default:
samplesAppended--
}