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-02-03 18:04:30 +0700
commit011e40da85bddf83fee0ded83cb9115b7a88b3d4 (patch)
tree355cc352e66fc64ce94f17658c31e699aa798bb1 /src/net/http
parent85232e51b20971e0d211b25fa3aa412bc7987404 (diff)
downloadgo-011e40da85bddf83fee0ded83cb9115b7a88b3d4.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 92bd94f72d..477d341f0b 100644
--- a/src/net/http/fs.go
+++ b/src/net/http/fs.go
@@ -1020,7 +1020,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)