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()
}