From 2ed810b369e433f442975d151fcf5eaca7e6d67b Mon Sep 17 00:00:00 2001 From: lowang-bh Date: Wed, 2 Aug 2023 10:17:29 +0800 Subject: [PATCH] enhancemant: make map with cap Signed-off-by: lowang-bh --- pkg/controllers/apis/job_info.go | 4 ++-- pkg/scheduler/api/job_info.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/controllers/apis/job_info.go b/pkg/controllers/apis/job_info.go index 2094ed0a1b..aec52378b5 100644 --- a/pkg/controllers/apis/job_info.go +++ b/pkg/controllers/apis/job_info.go @@ -40,11 +40,11 @@ func (ji *JobInfo) Clone() *JobInfo { Name: ji.Name, Job: ji.Job, - Pods: make(map[string]map[string]*v1.Pod), + Pods: make(map[string]map[string]*v1.Pod, len(ji.Pods)), } for key, pods := range ji.Pods { - job.Pods[key] = make(map[string]*v1.Pod) + job.Pods[key] = make(map[string]*v1.Pod, len(pods)) for pn, pod := range pods { job.Pods[key][pn] = pod } diff --git a/pkg/scheduler/api/job_info.go b/pkg/scheduler/api/job_info.go index f4b4601aa9..efb0316e96 100644 --- a/pkg/scheduler/api/job_info.go +++ b/pkg/scheduler/api/job_info.go @@ -574,7 +574,7 @@ func (ji *JobInfo) Clone() *JobInfo { PodGroup: ji.PodGroup.Clone(), TaskStatusIndex: map[TaskStatus]tasksMap{}, - TaskMinAvailable: make(map[TaskID]int32), + TaskMinAvailable: make(map[TaskID]int32, len(ji.TaskMinAvailable)), TaskMinAvailableTotal: ji.TaskMinAvailableTotal, Tasks: tasksMap{}, Preemptable: ji.Preemptable,