aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2024-10-26 00:48:33 +0700
committerShulhan <m.shulhan@gmail.com>2026-04-14 21:51:40 +0700
commit8c0027ca7bde882aaa063044ac7c64ba5c7a6c92 (patch)
tree3180813916ed48f0cd2c22a97561cf988f636e91 /src/net/http
parent66e8a77e30babe052c023320d85af4c126413da8 (diff)
downloadgo-8c0027ca7bde882aaa063044ac7c64ba5c7a6c92.tar.xz
all: prealloc slice with possible minimum capabilities
Diffstat (limited to 'src/net/http')
-rw-r--r--src/net/http/cookiejar/jar.go2
-rw-r--r--src/net/http/fs.go4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/net/http/cookiejar/jar.go b/src/net/http/cookiejar/jar.go
index db6bcddb26..bad2a67f13 100644
--- a/src/net/http/cookiejar/jar.go
+++ b/src/net/http/cookiejar/jar.go
@@ -219,7 +219,7 @@ func (j *Jar) cookies(u *url.URL, now time.Time) (cookies []*http.Cookie) {
}
modified := false
- var selected []entry
+ selected := make([]entry, 0, len(submap))
for id, e := range submap {
if e.Persistent && !e.Expires.After(now) {
delete(submap, id)
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)