We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 28c93a7 commit 3475f2eCopy full SHA for 3475f2e
src/net/url/url.go
@@ -15,7 +15,6 @@ package url
15
import (
16
"errors"
17
"fmt"
18
- "maps"
19
"net/netip"
20
"path"
21
"slices"
@@ -1046,7 +1045,16 @@ func (v Values) Encode() string {
1046
1045
return ""
1047
}
1048
var buf strings.Builder
1049
- for _, k := range slices.Sorted(maps.Keys(v)) {
+ // To minimize allocations, we eschew iterators and pre-size the slice in
+ // which we collect v's keys.
1050
+ keys := make([]string, len(v))
1051
+ var i int
1052
+ for k := range v {
1053
+ keys[i] = k
1054
+ i++
1055
+ }
1056
+ slices.Sort(keys)
1057
+ for _, k := range keys {
1058
vs := v[k]
1059
keyEscaped := QueryEscape(k)
1060
for _, v := range vs {
0 commit comments