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>
This commit is contained in:
apocelipes 2025-04-17 08:19:48 +00:00 committed by Gopher Robot
parent 8a8efafa88
commit c889004615
4 changed files with 6 additions and 18 deletions

View File

@ -253,12 +253,8 @@ func NewGraph(prof *Profile, o *Options) *Graph {
if dw == 0 && w == 0 {
continue
}
for k := range seenNode {
delete(seenNode, k)
}
for k := range seenEdge {
delete(seenEdge, k)
}
clear(seenNode)
clear(seenEdge)
var parent *Node
// A residual edge goes over one or more nodes that were not kept.
residual := false

View File

@ -41,9 +41,7 @@ func (xh *xxhash64) reset() {
xh.v[3] = xxhPrime64c1
xh.v[3] = -xh.v[3]
for i := range xh.buf {
xh.buf[i] = 0
}
clear(xh.buf[:])
xh.cnt = 0
}

View File

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

View File

@ -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++ {