From c8c46e746b778c39727c588adf79aff34ab6f151 Mon Sep 17 00:00:00 2001 From: apocelipes Date: Fri, 8 Mar 2024 10:12:41 +0000 Subject: runtime: use built-in clear to simplify code Change-Id: Icb6d9ca996b4119d8636d9f7f6a56e510d74d059 GitHub-Last-Rev: 08178e8ff798f4a51860573788c9347a0fb6bc40 GitHub-Pull-Request: golang/go#66188 Reviewed-on: https://go-review.googlesource.com/c/go/+/569979 Reviewed-by: Keith Randall Reviewed-by: qiulaidongfeng <2645477756@qq.com> LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek Auto-Submit: Keith Randall Reviewed-by: Keith Randall --- src/runtime/mpallocbits.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/runtime/mpallocbits.go') diff --git a/src/runtime/mpallocbits.go b/src/runtime/mpallocbits.go index 6b5f15dbd8..9f447557c6 100644 --- a/src/runtime/mpallocbits.go +++ b/src/runtime/mpallocbits.go @@ -85,18 +85,14 @@ func (b *pageBits) clearRange(i, n uint) { _ = b[j/64] // Clear leading bits. b[i/64] &^= ^uint64(0) << (i % 64) - for k := i/64 + 1; k < j/64; k++ { - b[k] = 0 - } + clear(b[i/64+1 : j/64]) // Clear trailing bits. b[j/64] &^= (uint64(1) << (j%64 + 1)) - 1 } // clearAll frees all the bits of b. func (b *pageBits) clearAll() { - for i := range b { - b[i] = 0 - } + clear(b[:]) } // clearBlock64 clears the 64-bit aligned block of bits containing the i'th bit that -- cgit v1.3