1
0
mirror of https://github.com/golang/go synced 2024-11-22 10:34:46 -07:00

encoding/asn1: simplify appendFourDigits

The new code does not need a for-loop and is easier to read.

Change-Id: Ic182d63c4779c2179b721fcfaec362681284cc16
GitHub-Last-Rev: b3ee265df7
GitHub-Pull-Request: golang/go#63879
Reviewed-on: https://go-review.googlesource.com/c/go/+/538721
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
apocelipes 2024-03-26 06:44:26 +00:00 committed by Gopher Robot
parent ed9aed1c9d
commit 33fd95b820

View File

@ -355,12 +355,11 @@ func appendTwoDigits(dst []byte, v int) []byte {
}
func appendFourDigits(dst []byte, v int) []byte {
var bytes [4]byte
for i := range bytes {
bytes[3-i] = '0' + byte(v%10)
v /= 10
}
return append(dst, bytes[:]...)
return append(dst,
byte('0'+(v/1000)%10),
byte('0'+(v/100)%10),
byte('0'+(v/10)%10),
byte('0'+v%10))
}
func outsideUTCRange(t time.Time) bool {