From e4de0b988a7fd395e61f88cb9b64fbc45501323f Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sat, 17 Aug 2024 18:49:05 +0100 Subject: [PATCH] examples/hyprctl: avoid unnecessary append in usage --- examples/hyprctl/main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/hyprctl/main.go b/examples/hyprctl/main.go index 54e33c4..021287f 100644 --- a/examples/hyprctl/main.go +++ b/examples/hyprctl/main.go @@ -56,9 +56,11 @@ func usage(m map[string]func(args []string)) { fmt.Fprintf(out, "Available subcommands:\n") // Sort keys before printing, since Go randomises order - subcommands := make([]string, 0, len(m)) + subcommands := make([]string, len(m)) + i := 0 for s := range m { - subcommands = append(subcommands, s) + subcommands[i] = s + i++ } sort.Strings(subcommands) for _, s := range subcommands {