]> Sergey Matveev's repositories - mmc.git/commitdiff
Sorted user statuses
authorSergey Matveev <stargrave@stargrave.org>
Tue, 14 Mar 2023 08:23:47 +0000 (11:23 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 14 Mar 2023 08:23:47 +0000 (11:23 +0300)
cmd/mmc/main.go

index 9748be35d202e49a8d8d206c60fb92d35d80acec..9283745d0563ab514b0c78a8d67545f1220848b7 100644 (file)
@@ -329,15 +329,20 @@ func main() {
                                log.Println("OpenFile:", pth, err)
                                continue
                        }
-                       statuses := make(map[string][]string)
+                       agg := make(map[string][]string)
                        UserStatusM.RLock()
                        for name, status := range UserStatus {
-                               statuses[status] = append(statuses[status], name)
+                               agg[status] = append(agg[status], name)
                        }
                        UserStatusM.RUnlock()
-                       for status := range statuses {
-                               sort.Strings(statuses[status])
-                               fmt.Fprintln(fd, status+":", strings.Join(statuses[status], " "))
+                       statuses := make([]string, 0, len(agg))
+                       for status := range agg {
+                               sort.Strings(agg[status])
+                               statuses = append(statuses, status)
+                       }
+                       sort.Strings(statuses)
+                       for _, status := range statuses {
+                               fmt.Fprintln(fd, status+":", strings.Join(agg[status], " "))
                        }
                        fd.Close()
                }