Skip to content

Commit

Permalink
Update golang.org/x/exp to latest version
Browse files Browse the repository at this point in the history
The signature of the `slices.SortStableFunc` function has been changed.
  • Loading branch information
hansmi committed Oct 1, 2023
1 parent 57b4e66 commit 2629245
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.19
require (
github.com/google/go-cmp v0.5.9
github.com/hashicorp/golang-lru/v2 v2.0.6
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/text v0.13.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ github.com/hashicorp/golang-lru/v2 v2.0.6 h1:3xi/Cafd1NaoEnS/yDssIiuVeDVywU0QdFG
github.com/hashicorp/golang-lru/v2 v2.0.6/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
10 changes: 6 additions & 4 deletions mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ func (b mapperBuilder) build() *mapper {
}

// Sort longest entries first
slices.SortFunc(m.entries, func(a, b mapperEntry) bool {
if len(a.old) == len(b.old) {
return a.old < b.old
slices.SortFunc(m.entries, func(a, b mapperEntry) int {
if len(a.old) > len(b.old) {
return -1
} else if len(a.old) < len(b.old) {
return +1
}

return len(a.old) > len(b.old)
return strings.Compare(a.old, b.old)
})

return m
Expand Down
10 changes: 8 additions & 2 deletions registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ func (r *Registry) Best(tag language.Tag) (*Locale, language.Confidence) {
}

if r.tags == nil {
slices.SortStableFunc(r.items, func(a, b *registeredLocale) bool {
return a.priority < b.priority
slices.SortStableFunc(r.items, func(a, b *registeredLocale) int {
if a.priority < b.priority {
return -1
} else if a.priority > b.priority {
return +1
}

return 0
})

r.tags = make([]language.Tag, len(r.items))
Expand Down

0 comments on commit 2629245

Please sign in to comment.