Use efficient APIs and simplify loops

Minor refactors across the codebase to improve readability and use more efficient APIs: replace fmt.Sprintf+base64 encoding with fmt.Appendf when building Shadowsocks userInfo; compute elapsed using max(now-prev.at, window) to simplify logic; use strings.SplitSeq for splitting in two places; simplify test and goroutine loops to range-based iterations and use errgroup's Go helper; and align/clean up struct field formatting and test map literals. Mostly stylistic/efficiency changes with no intended behavior changes.
This commit is contained in:
MHSanaei
2026-06-23 14:12:28 +02:00
parent 852b53db79
commit 1c0b76c27a
8 changed files with 62 additions and 69 deletions
+1 -1
View File
@@ -429,7 +429,7 @@ func (s *Server) memoryAlarmWanted() bool {
if threshold <= 0 {
return false
}
for _, e := range strings.Split(events, ",") {
for e := range strings.SplitSeq(events, ",") {
if strings.TrimSpace(e) == string(eventbus.EventMemoryHigh) {
return true
}