github.com/ice-blockchain/go/src@v0.0.0-20240403114104-1564d284e521/sort/sort_impl_go121.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build go1.21 6 7 // Starting with Go 1.21, we can leverage the new generic functions from the 8 // slices package to implement some `sort` functions faster. However, until 9 // the bootstrap compiler uses Go 1.21 or later, we keep a fallback version 10 // in sort_impl_120.go that retains the old implementation. 11 12 package sort 13 14 import "slices" 15 16 func intsImpl(x []int) { slices.Sort(x) } 17 func float64sImpl(x []float64) { slices.Sort(x) } 18 func stringsImpl(x []string) { slices.Sort(x) } 19 20 func intsAreSortedImpl(x []int) bool { return slices.IsSorted(x) } 21 func float64sAreSortedImpl(x []float64) bool { return slices.IsSorted(x) } 22 func stringsAreSortedImpl(x []string) bool { return slices.IsSorted(x) }