Skip to content

Commit

Permalink
Simplify listCPURange implementation
Browse files Browse the repository at this point in the history
Continue early for single element range
  • Loading branch information
tklauser committed May 23, 2024
1 parent 9ff7f79 commit 9824f86
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions numcpus_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ func listCPURange(cpus string) ([]int, error) {
if err != nil {
return nil, err
}
var last uint64
if found {
last, err = strconv.ParseUint(to, 10, 32)
if err != nil {
return nil, err
}
} else {
last = first
if !found {
// range containing a single element
list = append(list, int(first))
continue
}
last, err := strconv.ParseUint(to, 10, 32)
if err != nil {
return nil, err
}
if last < first {
return nil, fmt.Errorf("last CPU in range (%d) less than first (%d)", last, first)
Expand Down

0 comments on commit 9824f86

Please sign in to comment.