Skip to content

Commit 6f3b8ac

Browse files
authored
Merge pull request #2843 from Juneezee/refactor/exp
Replace `golang.org/x/exp` with stdlib
2 parents c216e59 + f9ad2f2 commit 6f3b8ac

File tree

5 files changed

+10
-26
lines changed

5 files changed

+10
-26
lines changed

enginetest/histogram_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"testing"
1212

1313
"github.com/stretchr/testify/require"
14-
"golang.org/x/exp/rand"
1514

1615
"github.com/dolthub/go-mysql-server/memory"
1716
"github.com/dolthub/go-mysql-server/sql"
@@ -22,10 +21,6 @@ import (
2221
"github.com/dolthub/go-mysql-server/sql/types"
2322
)
2423

25-
func init() {
26-
rand.Seed(0)
27-
}
28-
2924
type statsTest struct {
3025
name string
3126
tableGen func(*sql.Context, *memory.Database, int, sql.TableId, sql.ColumnId, ...interface{}) *plan.ResolvedTable

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ require (
2020
github.com/stretchr/testify v1.9.0
2121
go.opentelemetry.io/otel v1.31.0
2222
go.opentelemetry.io/otel/trace v1.31.0
23-
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
2423
golang.org/x/sync v0.3.0
2524
golang.org/x/sys v0.12.0
2625
golang.org/x/text v0.6.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,6 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U
319319
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
320320
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
321321
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
322-
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
323-
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
324322
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
325323
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
326324
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

sql/encodings/generate/main.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
package main
1616

1717
import (
18+
"cmp"
1819
"encoding/binary"
1920
"fmt"
2021
"hash/fnv"
22+
"maps"
2123
"os"
22-
"sort"
24+
"slices"
2325
"strings"
2426
"unsafe"
25-
26-
"golang.org/x/exp/constraints"
2727
)
2828

2929
var Header = `// Copyright 2023 Dolthub, Inc.
@@ -89,7 +89,7 @@ func main() {
8989
weightKeys = append(weightKeys[:j], weightKeys[j+1:]...)
9090
}
9191
}
92-
sort.Strings(duplicateKeyNames)
92+
slices.Sort(duplicateKeyNames)
9393
// Find the common prefix of all names if they exist, else concatenate all names
9494
if len(duplicateKeyNames) > 0 {
9595
// Grab the duplicated map and delete the first key
@@ -337,13 +337,8 @@ var WeightMaps = map[string]map[rune]int32{
337337

338338
var FileContentHashes = map[string]uint64{}
339339

340-
func SortedMapKeys[K constraints.Ordered, V any](m map[K]V) []K {
341-
keys := make([]K, 0, len(m))
342-
for key := range m {
343-
keys = append(keys, key)
344-
}
345-
sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
346-
return keys
340+
func SortedMapKeys[K cmp.Ordered, V any](m map[K]V) []K {
341+
return slices.Sorted(maps.Keys(m))
347342
}
348343

349344
func CommonPrefix(str1 string, str2 string) string {

sql/types/json_value.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import (
2121
"encoding/json"
2222
"fmt"
2323
"io"
24+
"maps"
2425
"regexp"
25-
"sort"
26+
"slices"
2627
"strconv"
2728
"strings"
2829
"sync"
2930

3031
"github.com/dolthub/jsonpath"
3132
"github.com/shopspring/decimal"
32-
"golang.org/x/exp/maps"
3333

3434
"github.com/dolthub/go-mysql-server/sql"
3535
)
@@ -728,7 +728,7 @@ func jsonObjectKeyIntersection(a, b JsonObject) (ks []string) {
728728
ks = append(ks, key)
729729
}
730730
}
731-
sort.Strings(ks)
731+
slices.Sort(ks)
732732
return
733733
}
734734

@@ -1196,10 +1196,7 @@ type JSONIter struct {
11961196

11971197
func NewJSONIter(json JsonObject) JSONIter {
11981198
json = maps.Clone(json)
1199-
keys := maps.Keys(json)
1200-
sort.Slice(keys, func(i, j int) bool {
1201-
return keys[i] < keys[j]
1202-
})
1199+
keys := slices.Sorted(maps.Keys(json))
12031200
return JSONIter{
12041201
doc: &json,
12051202
keys: keys,

0 commit comments

Comments
 (0)