refract: reduce mem alloc while building str (#10261)

Signed-off-by: jayl1e <jayl1e@outlook.com>
This commit is contained in:
jay
2026-07-08 01:24:45 -07:00
committed by GitHub
parent c000addfc9
commit a16194f5b4
+3 -3
View File
@@ -1123,9 +1123,9 @@ func encodePath(pathName string) string {
if runeLen < 0 {
return pathName
}
u := make([]byte, runeLen)
utf8.EncodeRune(u, s)
for _, r := range u {
var u [utf8.UTFMax]byte
utf8.EncodeRune(u[:], s)
for _, r := range u[:runeLen] {
buf.WriteByte('%')
buf.WriteByte(pathHexTable[r>>4])
buf.WriteByte(pathHexTable[r&0x0f])