diff options
Diffstat (limited to 'src/sort/slice.go')
-rw-r--r-- | src/sort/slice.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/sort/slice.go b/src/sort/slice.go index 443182b42e..d0b2102013 100644 --- a/src/sort/slice.go +++ b/src/sort/slice.go @@ -4,7 +4,10 @@ package sort -import "math/bits" +import ( + "internal/reflectlite" + "math/bits" +) // Slice sorts the slice x given the provided less function. // It panics if x is not a slice. @@ -16,8 +19,8 @@ import "math/bits" // The less function must satisfy the same requirements as // the Interface type's Less method. func Slice(x any, less func(i, j int) bool) { - rv := reflectValueOf(x) - swap := reflectSwapper(x) + rv := reflectlite.ValueOf(x) + swap := reflectlite.Swapper(x) length := rv.Len() limit := bits.Len(uint(length)) pdqsort_func(lessSwap{less, swap}, 0, length, limit) @@ -30,15 +33,15 @@ func Slice(x any, less func(i, j int) bool) { // The less function must satisfy the same requirements as // the Interface type's Less method. func SliceStable(x any, less func(i, j int) bool) { - rv := reflectValueOf(x) - swap := reflectSwapper(x) + rv := reflectlite.ValueOf(x) + swap := reflectlite.Swapper(x) stable_func(lessSwap{less, swap}, rv.Len()) } // SliceIsSorted reports whether the slice x is sorted according to the provided less function. // It panics if x is not a slice. func SliceIsSorted(x any, less func(i, j int) bool) bool { - rv := reflectValueOf(x) + rv := reflectlite.ValueOf(x) n := rv.Len() for i := n - 1; i > 0; i-- { if less(i, i-1) { |