From 08826094ce10142cd0524bfd0eed47612aa6c842 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 5 Jun 2023 15:09:09 +0200 Subject: [PATCH] added preallocation of size --- cmd/fs/ls.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/fs/ls.go b/cmd/fs/ls.go index 2e1e4f61f..85e3ffdfa 100644 --- a/cmd/fs/ls.go +++ b/cmd/fs/ls.go @@ -59,13 +59,13 @@ var lsCmd = &cobra.Command{ return err } - jsonDirEntries := make([]jsonDirEntry, 0) - for _, entry := range entries { + jsonDirEntries := make([]jsonDirEntry, len(entries)) + for i, entry := range entries { jsonDirEntry, err := toJsonDirEntry(entry) if err != nil { return err } - jsonDirEntries = append(jsonDirEntries, *jsonDirEntry) + jsonDirEntries[i] = *jsonDirEntry } sort.Slice(jsonDirEntries, func(i, j int) bool { return jsonDirEntries[i].Name < jsonDirEntries[j].Name