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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user