kubelet: Avoid allocating multiple times during status

Noticed while reviewing this code path. We can assume the
temporary slice should be about the same size as it was previously.
This commit is contained in:
Clayton Coleman 2021-07-19 17:55:18 -04:00
parent 9efd40d72a
commit c2a6d07b8f
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -1782,7 +1782,7 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
if isInitContainer {
return kubetypes.SortStatusesOfInitContainers(pod, statuses)
}
var containerStatuses []v1.ContainerStatus
containerStatuses := make([]v1.ContainerStatus, 0, len(statuses))
for _, status := range statuses {
containerStatuses = append(containerStatuses, *status)
}