1
0
mirror of https://github.com/golang/go synced 2024-11-23 16:20:04 -07:00

net/url: reduce allocs on resolvePath func

pregrow result array to avoid small allocation.

Change-Id: Ife5f815efa4c163ecdbb3a4c16bfb60a484dfa11
Reviewed-on: https://go-review.googlesource.com/c/go/+/174706
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
sergey 2019-05-02 18:07:34 +03:00 committed by Brad Fitzpatrick
parent 4692343cf4
commit 3e5c04313c

View File

@ -950,8 +950,8 @@ func resolvePath(base, ref string) string {
if full == "" { if full == "" {
return "" return ""
} }
var dst []string
src := strings.Split(full, "/") src := strings.Split(full, "/")
dst := make([]string, 0, len(src))
for _, elem := range src { for _, elem := range src {
switch elem { switch elem {
case ".": case ".":