Optimize: file /cpuset slice make cap (#112270)

This commit is contained in:
jesse.tang 2022-10-01 07:56:25 +08:00 committed by GitHub
parent 5bcdc82911
commit 759e043136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}
@ -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)
}
@ -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))
}
@ -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))
}