-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: adopt "slices" stdlib package for sorting #124363
*: adopt "slices" stdlib package for sorting #124363
Conversation
104d9d7
to
7ee1c41
Compare
7ee1c41
to
2ce5985
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 7 files at r1, 12 of 12 files at r2, 1 of 1 files at r3, 20 of 20 files at r4, 23 of 23 files at r5, 1 of 1 files at r6, 6 of 6 files at r7, 38 of 38 files at r8, 11 of 11 files at r9, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @abarganier, @DrewKimball, @dt, @nameisbhaskar, @nvanbenschoten, @vidit-bhat, and @wenyihu6)
pkg/sql/sem/tree/datum.go
line 4817 at r7 (raw file):
func (d *DTuple) sort(ctx CompareContext) { if !d.sorted { lessFn := func(a, b Datum) int {
nit: consider rename to sortFn
or similar.
2ce5985
to
e8bc9e3
Compare
The "cmp" package was added to the stdlib in Go 1.21. Epic: None Release note: None
The "slices" package was added to the stdlib in Go 1.21. Epic: None Release note: None
This commit replaces some of usages of sort.IsSorted with uses of slices.IsSortedFunc, where doing so makes sense. As of Go 1.21, the docs on sort.IsSorted say: > Note: in many situations, the newer slices.IsSortedFunc function is > more ergonomic and runs faster. Epic: None Release note: None
This commit replaces some of usages of sort.SliceIsSorted with uses of slices.IsSortedFunc, where doing so makes sense. As of Go 1.21, the docs on sort.SliceIsSorted say: > Note: in many situations, the newer slices.IsSortedFunc function is > more ergonomic and runs faster. Epic: None Release note: None
e8bc9e3
to
4057d65
Compare
This commit replaces some of usages of sort.Slice with uses of slices.SortFunc, where doing so makes sense. As of Go 1.21, the docs on sort.Slice say: > Note: in many situations, the newer slices.SortFunc function is > more ergonomic and runs faster. This commit only makes these changes in production kv code for now, because replacing the other 200 or so uses of sort.Slice would be a lot of churn with less benefit. Epic: None Release note: None
This commit replaces some of usages of sort.Slice with uses of slices.Sort, where doing so makes sense. As of Go 1.21, the docs on sort.Slice say: > Note: in many situations, the newer slices.SortFunc function is > more ergonomic and runs faster. Epic: None Release note: None
4057d65
to
50acd41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR!
bors r=kvoli
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @abarganier, @DrewKimball, @dt, @kvoli, @nameisbhaskar, @vidit-bhat, and @wenyihu6)
pkg/sql/sem/tree/datum.go
line 4817 at r7 (raw file):
Previously, kvoli (Austen) wrote…
nit: consider rename to
sortFn
or similar.
Done.
This PR adopts the new "slices" package for sorting, where doing so makes sense. This package was added to the Go standard library in Go 1.21. It uses generics to improve the ergonomics and performance of sorting and searching related tasks.
@kvoli assigning you as a reviewer because allocator-related code seems to be the biggest user of sorting around.
See individual commits.