From 33c00f8189ba97933cc5b37a24220c037e09afbd Mon Sep 17 00:00:00 2001 From: kychen Date: Mon, 10 Jul 2023 11:51:00 +0800 Subject: [PATCH] fix: pre alloc silice. --- resource/resources.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resource/resources.go b/resource/resources.go index e4cc7bf8..17267951 100644 --- a/resource/resources.go +++ b/resource/resources.go @@ -27,7 +27,8 @@ func SumResources(resources ...corev1.ResourceRequirements) corev1.ResourceRequi return corev1.ResourceRequirements{} } - var sumLimits, sumRequests []corev1.ResourceList + sumLimits := make([]corev1.ResourceList, 0, len(resources)) + sumRequests := make([]corev1.ResourceList, 0, len(resources)) for _, item := range resources { sumLimits = append(sumLimits, item.Limits) sumRequests = append(sumRequests, item.Requests)