Replace fmt.Sprint with strconv.Itoa, specify slice capacity

Uber's Go style guide outlines a slight performance benefit when using
strconv over fmt:
https://github.com/uber-go/guide/blob/dc025303c14891f54d1847396379548773e6123e/style.md#prefer-strconv-over-fmt

Also specifiying slice capacity when it is known beforehand:
https://github.com/uber-go/guide/blob/dc025303c14891f54d1847396379548773e6123e/style.md#specifying-slice-capacity

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-09-29 13:52:12 -04:00
parent 022cfd5cb1
commit 15ee94fbbe
7 changed files with 15 additions and 8 deletions
+1
View File
@@ -398,6 +398,7 @@ func (l *trophyList) UnmarshalJSON(b []byte) error {
return err
}
*l = make(trophyList, 0, len(root.Trophies))
for _, thing := range root.Trophies {
if trophy, ok := thing.Trophy(); ok {
*l = append(*l, trophy)