diff options
author | Shulhan <ms@kilabit.info> | 2019-01-31 01:26:08 +0700 |
---|---|---|
committer | Erik Dubbelboer <erik@dubbelboer.com> | 2019-01-30 20:42:28 +0100 |
commit | 4c53f113c5e6b3399fd93214f0bd1b5d5f19f1a5 (patch) | |
tree | 17ca0788c62562ea3f9c93932fbc6956007a974d /fs.go | |
parent | Add warning to DoTimeout (diff) | |
download | fasthttp-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.go | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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) { |