mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-06 16:05:05 +02:00
Bump go version to 1.21
Allows us to use the much faster builtin min/max functions for two variable min/max
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -98,19 +99,13 @@ func sort_with_key[T any, C constraints.Ordered](stable bool, s []T, key func(a
|
||||
for i, x := range s {
|
||||
temp[i].val, temp[i].key = x, key(x)
|
||||
}
|
||||
cmp := func(a, b t) int {
|
||||
if a.key < b.key {
|
||||
return -1
|
||||
}
|
||||
if a.key > b.key {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
key_cmp := func(a, b t) int {
|
||||
return cmp.Compare(a.key, b.key)
|
||||
}
|
||||
if stable {
|
||||
slices.SortStableFunc(temp, cmp)
|
||||
slices.SortStableFunc(temp, key_cmp)
|
||||
} else {
|
||||
slices.SortFunc(temp, cmp)
|
||||
slices.SortFunc(temp, key_cmp)
|
||||
}
|
||||
for i, x := range temp {
|
||||
s[i] = x.val
|
||||
|
||||
Reference in New Issue
Block a user