mirror of
https://github.com/go-gitea/gitea
synced 2024-11-15 22:41:44 +01:00
9607750b5e
`hex.EncodeToString` has better performance than `fmt.Sprintf("%x", []byte)`, we should use it as much as possible. I'm not an extreme fan of performance, so I think there are some exceptions: - `fmt.Sprintf("%x", func(...)[N]byte())` - We can't slice the function return value directly, and it's not worth adding lines. ```diff func A()[20]byte { ... } - a := fmt.Sprintf("%x", A()) - a := hex.EncodeToString(A()[:]) // invalid + tmp := A() + a := hex.EncodeToString(tmp[:]) ``` - `fmt.Sprintf("%X", []byte)` - `strings.ToUpper(hex.EncodeToString(bytes))` has even worse performance. |
||
---|---|---|
.. | ||
avatar.go | ||
badge.go | ||
email_address.go | ||
email_address_test.go | ||
error.go | ||
external_login_user.go | ||
follow.go | ||
follow_test.go | ||
list.go | ||
main_test.go | ||
openid.go | ||
openid_test.go | ||
redirect.go | ||
redirect_test.go | ||
search.go | ||
setting.go | ||
setting_keys.go | ||
setting_test.go | ||
user.go | ||
user_test.go | ||
user_update.go |