Avoid potential reallocs by pre-sizing some slices
There's a couple spots where we know exactly how large the destination buffer should be, so pre-size these to avoid any reallocs to a higher capacity. Signed-off-by: Danny Canter <danny@dcantah.dev>
This commit is contained in:
@@ -64,9 +64,9 @@ func commonContainerToNRI(ctr Container) *nri.Container {
|
||||
}
|
||||
|
||||
func containersToNRI(ctrList []Container) []*nri.Container {
|
||||
ctrs := []*nri.Container{}
|
||||
for _, ctr := range ctrList {
|
||||
ctrs = append(ctrs, containerToNRI(ctr))
|
||||
ctrs := make([]*nri.Container, len(ctrList))
|
||||
for i, ctr := range ctrList {
|
||||
ctrs[i] = containerToNRI(ctr)
|
||||
}
|
||||
return ctrs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user