Skip to content

Commit

Permalink
enhancemant: make map with cap
Browse files Browse the repository at this point in the history
Signed-off-by: lowang-bh <lhui_wang@163.com>
  • Loading branch information
lowang-bh committed Aug 2, 2023
1 parent 5811bd3 commit 2ed810b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/controllers/apis/job_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/api/job_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2ed810b

Please sign in to comment.