Merge pull request #10488 from dcantah/avoid-realloc

Avoid potential reallocs by pre-sizing some slices
This commit is contained in:
Samuel Karp
2024-07-22 05:39:19 +00:00
committed by GitHub
5 changed files with 17 additions and 17 deletions

View File

@@ -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
}