Skip to content

Commit 853b514

Browse files
1911860538gopherbot
1911860538
authored andcommitted
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: 5445b54 GitHub-Pull-Request: #72820 Reviewed-on: https://go-review.googlesource.com/c/go/+/657055 Reviewed-by: David Chase <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent c1c7e59 commit 853b514

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/time/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ func quote(s string) string {
891891
if c == '"' || c == '\\' {
892892
buf = append(buf, '\\')
893893
}
894-
buf = append(buf, string(c)...)
894+
buf = append(buf, byte(c))
895895
}
896896
}
897897
buf = append(buf, '"')

0 commit comments

Comments
 (0)