refactor: modernize Go with strings.SplitSeq and maps.Copy
Replace strings.Split loops with strings.SplitSeq iterators in the CSV parsers (reality_scan and the scale-test helpers) and swap a manual map copy for maps.Copy in the MTProto traffic collector. No behavior change; these are the fixes the modernize analyzer reports.
This commit is contained in:
5 files changed
+6
-7
No files matched your search
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -413,9 +414,7 @@ func (m *Manager) CollectTraffic() ([]Traffic, []string) {
|
||||
continue
|
||||
}
|
||||
lastCopy := make(map[string]clientCounters, len(cur.last))
|
||||
for k, v := range cur.last {
|
||||
lastCopy[k] = v
|
||||
}
|
||||
maps.Copy(lastCopy, cur.last)
|
||||
snaps = append(snaps, snap{id: id, apiPort: cur.apiPort, apiToken: cur.apiToken, tag: cur.tag, last: lastCopy})
|
||||
}
|
||||
m.mu.Unlock()
|
||||
|
||||
@@ -54,7 +54,7 @@ func scaleSubSizes(t *testing.T, def ...int) []int {
|
||||
return def
|
||||
}
|
||||
var out []int
|
||||
for _, part := range strings.Split(raw, ",") {
|
||||
for part := range strings.SplitSeq(raw, ",") {
|
||||
part = strings.TrimSpace(part)
|
||||
if part == "" {
|
||||
continue
|
||||
|
||||
@@ -51,7 +51,7 @@ func scaleJobSizes(t *testing.T, def ...int) []int {
|
||||
return def
|
||||
}
|
||||
var out []int
|
||||
for _, part := range strings.Split(raw, ",") {
|
||||
for part := range strings.SplitSeq(raw, ",") {
|
||||
part = strings.TrimSpace(part)
|
||||
if part == "" {
|
||||
continue
|
||||
|
||||
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user