diff options
| author | Shulhan <m.shulhan@gmail.com> | 2024-10-26 00:48:33 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2026-04-14 21:51:40 +0700 |
| commit | 8c0027ca7bde882aaa063044ac7c64ba5c7a6c92 (patch) | |
| tree | 3180813916ed48f0cd2c22a97561cf988f636e91 /src/net/http/fs.go | |
| parent | 66e8a77e30babe052c023320d85af4c126413da8 (diff) | |
| download | go-8c0027ca7bde882aaa063044ac7c64ba5c7a6c92.tar.xz | |
all: prealloc slice with possible minimum capabilities
Diffstat (limited to 'src/net/http/fs.go')
| -rw-r--r-- | src/net/http/fs.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/net/http/fs.go b/src/net/http/fs.go index 821b9b1266..26b9fc0adf 100644 --- a/src/net/http/fs.go +++ b/src/net/http/fs.go @@ -1021,7 +1021,9 @@ func parseRange(s string, size int64) ([]httpRange, error) { if !strings.HasPrefix(s, b) { return nil, errors.New("invalid range") } - var ranges []httpRange + + splits := strings.Split(s[len(b):], ",") + ranges := make([]httpRange, 0, len(splits)) noOverlap := false for ra := range strings.SplitSeq(s[len(b):], ",") { ra = textproto.TrimString(ra) |
