Skip to content

Commit a9ea4d6

Browse files
Disallow slow sorting (#3981)
1 parent 092928c commit a9ea4d6

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ linters-settings:
112112
- 'require\.EqualValues$(# Equal should be used instead)?'
113113
- 'require\.NotEqualValues$(# NotEqual should be used instead)?'
114114
- '^(t|b|tb|f)\.(Fatal|Fatalf|Error|Errorf)$(# the require library should be used instead)?'
115+
- '^sort\.(Slice|Strings)$(# the slices package should be used instead)?'
115116
# Exclude godoc examples from forbidigo checks.
116117
exclude_godoc_examples: false
117118
gci:

vms/platformvm/validator_set_property_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"errors"
99
"fmt"
1010
"reflect"
11-
"sort"
11+
"slices"
1212
"testing"
1313
"time"
1414

@@ -153,7 +153,7 @@ func TestGetValidatorsSetProperty(t *testing.T) {
153153
// Checks: let's look back at validator sets at previous heights and
154154
// make sure they match the snapshots already taken
155155
snapshotHeights := maps.Keys(validatorSetByHeightAndSubnet)
156-
sort.Slice(snapshotHeights, func(i, j int) bool { return snapshotHeights[i] < snapshotHeights[j] })
156+
slices.Sort(snapshotHeights)
157157
for idx, snapShotHeight := range snapshotHeights {
158158
lastAcceptedHeight, err := vm.GetCurrentHeight(context.Background())
159159
if err != nil {

x/merkledb/view_iterator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"bytes"
88
"context"
99
"math/rand"
10-
"sort"
10+
"slices"
1111
"testing"
1212
"time"
1313

@@ -258,7 +258,7 @@ func Test_View_Iterator_Random(t *testing.T) {
258258

259259
iter := view3.NewIterator()
260260
uniqueKeys := maps.Keys(uniqueKeyChanges)
261-
sort.Strings(uniqueKeys)
261+
slices.Sort(uniqueKeys)
262262
i := 0
263263
for iter.Next() {
264264
expectedKey := uniqueKeys[i]

0 commit comments

Comments
 (0)