From 5d888ac2c654a3ac00cd4b608cba0ca1dce47678 Mon Sep 17 00:00:00 2001 From: Vivek V Date: Fri, 25 Oct 2019 13:47:33 +0530 Subject: Added capacity to slice creation, when capacity is known (#159) Simple optimization to reduce memory allocations and copying when appending. --- filesystem/filesystem.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'filesystem') diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index a11f908..ee332c8 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -528,7 +528,7 @@ func (m *Mount) listDirectory(directoryPath string) ([]string, error) { return nil, err } - var descriptors []string + descriptors := make([]string, 0, len(names)) for _, name := range names { // Be sure to include links as well descriptors = append(descriptors, strings.TrimSuffix(name, linkFileExtension)) -- cgit v1.2.3