Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize: file /cpuset slice make cap #112270

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/kubelet/cm/cpuset/cpuset.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (s CPUSet) Difference(s2 CPUSet) CPUSet {
// ToSlice returns a slice of integers that contains all elements from
// this set.
func (s CPUSet) ToSlice() []int {
result := []int{}
result := make([]int, 0, len(s.elems))
for cpu := range s.elems {
result = append(result, cpu)
}
Expand All @@ -202,7 +202,7 @@ func (s CPUSet) ToSlice() []int {
// ToSliceNoSort returns a slice of integers that contains all elements from
// this set.
func (s CPUSet) ToSliceNoSort() []int {
result := []int{}
result := make([]int, 0, len(s.elems))
for cpu := range s.elems {
result = append(result, cpu)
}
Expand All @@ -212,7 +212,7 @@ func (s CPUSet) ToSliceNoSort() []int {
// ToSliceInt64 returns an ordered slice of int64 that contains all elements from
// this set
func (s CPUSet) ToSliceInt64() []int64 {
var result []int64
result := make([]int64, 0, len(s.elems))
for cpu := range s.elems {
result = append(result, int64(cpu))
}
Expand All @@ -223,7 +223,7 @@ func (s CPUSet) ToSliceInt64() []int64 {
// ToSliceNoSortInt64 returns a slice of int64 that contains all elements from
// this set.
func (s CPUSet) ToSliceNoSortInt64() []int64 {
var result []int64
result := make([]int64, 0, len(s.elems))
for cpu := range s.elems {
result = append(result, int64(cpu))
}
Expand Down