mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
all: use new Go 1.23 slices.Sorted more
Updates #12912 Change-Id: If1294e5bc7b5d3cf0067535ae10db75e8b988d8b Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
fd6686d81a
commit
3d401c11fa
@ -19,7 +19,6 @@
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
xmaps "golang.org/x/exp/maps"
|
||||
"tailscale.com/control/controlknobs"
|
||||
"tailscale.com/envknob"
|
||||
"tailscale.com/tailcfg"
|
||||
@ -313,10 +312,8 @@ func (ms *mapSession) updateStateFromResponse(resp *tailcfg.MapResponse) {
|
||||
}
|
||||
}
|
||||
if packetFilterChanged {
|
||||
keys := xmaps.Keys(ms.namedPacketFilters)
|
||||
sort.Strings(keys)
|
||||
var concat []tailcfg.FilterRule
|
||||
for _, v := range keys {
|
||||
for _, v := range slices.Sorted(maps.Keys(ms.namedPacketFilters)) {
|
||||
concat = ms.namedPacketFilters[v].AppendTo(concat)
|
||||
}
|
||||
ms.lastPacketFilterRules = views.SliceOf(concat)
|
||||
|
@ -20,10 +20,11 @@
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -76,12 +77,7 @@ func LogCurrent(logf logf) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
list := make([]string, 0, len(set))
|
||||
for k := range set {
|
||||
list = append(list, k)
|
||||
}
|
||||
sort.Strings(list)
|
||||
for _, k := range list {
|
||||
for _, k := range slices.Sorted(maps.Keys(set)) {
|
||||
logf("envknob: %s=%q", k, set[k])
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,12 @@
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/netip"
|
||||
"reflect"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -593,13 +593,7 @@ func TestMakeProbePlan(t *testing.T) {
|
||||
|
||||
func (plan probePlan) String() string {
|
||||
var sb strings.Builder
|
||||
keys := []string{}
|
||||
for k := range plan {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, key := range keys {
|
||||
for _, key := range slices.Sorted(maps.Keys(plan)) {
|
||||
fmt.Fprintf(&sb, "[%s]", key)
|
||||
pv := plan[key]
|
||||
for _, p := range pv {
|
||||
|
@ -7,11 +7,12 @@
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net"
|
||||
"net/netip"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sort"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
"unsafe"
|
||||
@ -907,12 +908,7 @@ func (c *Conn) foreachActiveDerpSortedLocked(fn func(regionID int, ad activeDerp
|
||||
}
|
||||
return
|
||||
}
|
||||
ids := make([]int, 0, len(c.activeDerp))
|
||||
for id := range c.activeDerp {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
sort.Ints(ids)
|
||||
for _, id := range ids {
|
||||
for _, id := range slices.Sorted(maps.Keys(c.activeDerp)) {
|
||||
fn(id, c.activeDerp[id])
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user