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
+2
View File
@@ -91,6 +91,7 @@ func (l *WidgetList) UnmarshalJSON(data []byte) error {
return err
}
*l = make(WidgetList, 0, len(widgetMap))
for _, w := range widgetMap {
root := new(rootWidget)
err = json.Unmarshal(w, root)
@@ -301,6 +302,7 @@ func (l *WidgetLinkList) UnmarshalJSON(data []byte) error {
return err
}
*l = make(WidgetLinkList, 0, len(dataMap))
for _, d := range dataMap {
var widgetLinkDataMap map[string]json.RawMessage
err = json.Unmarshal(d, &widgetLinkDataMap)