Skip to content

Commit

Permalink
use go 1.22 slices.Sort for more efficient, no-alloc sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-wa committed Sep 4, 2024
1 parent 2a8182b commit 24b77fe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/demoinfocs/s2_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package demoinfocs
import (
"bytes"
"fmt"
"sort"
"slices"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -320,8 +320,8 @@ func (p *parser) handleDemoPacket(pack *msgs2.CDemoPacket) {
p.pendingMessagesCache = append(p.pendingMessagesCache, pendingMessage{t, buf})
}

sort.SliceStable(p.pendingMessagesCache, func(i, j int) bool {
return p.pendingMessagesCache[i].priority() < p.pendingMessagesCache[j].priority()
slices.SortStableFunc(p.pendingMessagesCache, func(a, b pendingMessage) int {
return a.priority() - b.priority()
})

for _, m := range p.pendingMessagesCache {
Expand Down

0 comments on commit 24b77fe

Please sign in to comment.