From 9bd37534d8d5917ab389c2eadec7547c0c52f20b Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Fri, 22 Aug 2025 15:36:32 +0000 Subject: [PATCH] unix: switch (*CPUSet).Zero to clear builtin clear was added to Go 1.21 and is better than the manual loop approach. Change-Id: I851203714446e21b6329e2bcf308f2571d339e36 GitHub-Last-Rev: 71dc7f073e50a43a11ab10d3d9ef35ebe5b183f5 GitHub-Pull-Request: golang/sys#262 Reviewed-on: https://go-review.googlesource.com/c/sys/+/698495 Reviewed-by: Keith Randall Reviewed-by: Cherry Mui Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: Tobias Klauser Auto-Submit: Keith Randall --- unix/affinity_linux.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/unix/affinity_linux.go b/unix/affinity_linux.go index 6e5c81ac..3c7a6d6e 100644 --- a/unix/affinity_linux.go +++ b/unix/affinity_linux.go @@ -38,9 +38,7 @@ func SchedSetaffinity(pid int, set *CPUSet) error { // Zero clears the set s, so that it contains no CPUs. func (s *CPUSet) Zero() { - for i := range s { - s[i] = 0 - } + clear(s[:]) } func cpuBitsIndex(cpu int) int {