aboutsummaryrefslogtreecommitdiff
path: root/fs.go
diff options
context:
space:
mode:
authorGravatar Shulhan <ms@kilabit.info> 2019-01-31 01:26:08 +0700
committerGravatar Erik Dubbelboer <erik@dubbelboer.com> 2019-01-30 20:42:28 +0100
commit4c53f113c5e6b3399fd93214f0bd1b5d5f19f1a5 (patch)
tree17ca0788c62562ea3f9c93932fbc6956007a974d /fs.go
parentAdd warning to DoTimeout (diff)
downloadfasthttp-4c53f113c5e6b3399fd93214f0bd1b5d5f19f1a5.tar.gz
fasthttp-4c53f113c5e6b3399fd93214f0bd1b5d5f19f1a5.tar.bz2
fasthttp-4c53f113c5e6b3399fd93214f0bd1b5d5f19f1a5.zip
all: pre-allocated slice with possible known size
This fix is based on suggestion of "prealloc" static analysis tool [1]. Per note of the tool's author suggestion, its recommended to allocate the slice length/capability, if we known their possible size. This is to minimize "append" to re-allocate the slice underlying array. [1] https://github.com/alexkohler/prealloc
Diffstat (limited to 'fs.go')
-rw-r--r--fs.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs.go b/fs.go
index 7a73a79..b0f2e76 100644
--- a/fs.go
+++ b/fs.go
@@ -943,7 +943,7 @@ func (h *fsHandler) createDirIndex(base *URI, dirPath string, mustCompress bool)
}
fm := make(map[string]os.FileInfo, len(fileinfos))
- var filenames []string
+ filenames := make([]string, 0, len(fileinfos))
for _, fi := range fileinfos {
name := fi.Name()
if strings.HasSuffix(name, h.compressedFileSuffix) {