diff options
| author | Shulhan <m.shulhan@gmail.com> | 2023-05-02 01:06:11 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2024-01-25 04:01:14 +0700 |
| commit | 8096b47dd09fcda8712f7a3c07dced5244123a4d (patch) | |
| tree | 26339e20861f0d89cff1cf3dc763d7b99b4aaee8 /src/net/http/fs.go | |
| parent | 54386c4a7e68ab281545116220600f670e8f9e14 (diff) | |
| download | go-8096b47dd09fcda8712f7a3c07dced5244123a4d.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 | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/net/http/fs.go b/src/net/http/fs.go index af7511a7a4..45187eea14 100644 --- a/src/net/http/fs.go +++ b/src/net/http/fs.go @@ -961,9 +961,11 @@ 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.Split(s[len(b):], ",") { + for _, ra := range splits { ra = textproto.TrimString(ra) if ra == "" { continue |
