aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorapocelipes <seve3r@outlook.com>2025-04-17 08:19:48 +0000
committerGopher Robot <gobot@golang.org>2025-04-18 04:21:17 -0700
commitc889004615b40535ebd5054cbcf2deebdb3a299a (patch)
treeba385e9a08111cc151ea2e4fad560363486c808d /src/runtime
parent8a8efafa8835b646955dd46f4f466d3126e56200 (diff)
downloadgo-c889004615b40535ebd5054cbcf2deebdb3a299a.tar.xz
internal,runtime: use the builtin clear
To simplify the code. Change-Id: I023de705504c0b580718eec3c7c563b6cf2c8184 GitHub-Last-Rev: 026b32c799b13d0c7ded54f2e61429e6c5ed0aa8 GitHub-Pull-Request: golang/go#73412 Reviewed-on: https://go-review.googlesource.com/c/go/+/666118 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/mstats.go4
-rw-r--r--src/runtime/proc.go8
2 files changed, 3 insertions, 9 deletions
diff --git a/src/runtime/mstats.go b/src/runtime/mstats.go
index c10ca40221..888798c600 100644
--- a/src/runtime/mstats.go
+++ b/src/runtime/mstats.go
@@ -834,9 +834,7 @@ func (m *consistentHeapStats) unsafeRead(out *heapStatsDelta) {
func (m *consistentHeapStats) unsafeClear() {
assertWorldStopped()
- for i := range m.stats {
- m.stats[i] = heapStatsDelta{}
- }
+ clear(m.stats[:])
}
// read takes a globally consistent snapshot of m
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 8f07b39360..db7a5b2bb1 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -5690,14 +5690,10 @@ func (pp *p) destroy() {
wbBufFlush1(pp)
pp.gcw.dispose()
}
- for i := range pp.sudogbuf {
- pp.sudogbuf[i] = nil
- }
+ clear(pp.sudogbuf[:])
pp.sudogcache = pp.sudogbuf[:0]
pp.pinnerCache = nil
- for j := range pp.deferpoolbuf {
- pp.deferpoolbuf[j] = nil
- }
+ clear(pp.deferpoolbuf[:])
pp.deferpool = pp.deferpoolbuf[:0]
systemstack(func() {
for i := 0; i < pp.mspancache.len; i++ {