From: 1911860538 Date: Thu, 13 Mar 2025 11:57:51 +0000 (+0000) Subject: time: optimize quote using byte(c) for ASCII X-Git-Tag: go1.25rc1~707 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=853b514417dab2cf0383e48207caff2ce0305618;p=gostls13.git time: optimize quote using byte(c) for ASCII Since c < runeSelf && c >= ' ' (i.e., 32 <= c < 128), using buf = append(buf, byte(c)) instead of buf = append(buf, string(c)...) is a better choice, as it provides better performance. Change-Id: Ic0ab25c71634a1814267f4d85be2ebd8a3d44676 GitHub-Last-Rev: 5445b547712bbfc77a5c17d76194291c22eb4a05 GitHub-Pull-Request: golang/go#72820 Reviewed-on: https://go-review.googlesource.com/c/go/+/657055 Reviewed-by: David Chase Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Auto-Submit: Ian Lance Taylor --- diff --git a/src/time/format.go b/src/time/format.go index da1bac5ac3..87e990d48a 100644 --- a/src/time/format.go +++ b/src/time/format.go @@ -891,7 +891,7 @@ func quote(s string) string { if c == '"' || c == '\\' { buf = append(buf, '\\') } - buf = append(buf, string(c)...) + buf = append(buf, byte(c)) } } buf = append(buf, '"')