runtime: make use of builtin clear in tests

This is a follow-up to CL 574675.

Change-Id: I98c3ea968e9c7dc61472849c385a1e697568aa30
Reviewed-on: https://go-review.googlesource.com/c/go/+/574975
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Jes Cok <xigua67damn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Jes Cok 2024-03-28 12:50:04 +08:00 committed by Gopher Robot
parent 8f59b28fb3
commit 2830d5457e
2 changed files with 2 additions and 6 deletions

View file

@ -339,9 +339,7 @@ type BytesKey struct {
}
func (k *BytesKey) clear() {
for i := range k.b {
k.b[i] = 0
}
clear(k.b)
}
func (k *BytesKey) random(r *rand.Rand) {
randBytes(r, k.b)

View file

@ -451,9 +451,7 @@ func BenchmarkGoMemclr(b *testing.B) {
benchmarkSizes(b, []int{5, 16, 64, 256}, func(b *testing.B, n int) {
x := make([]byte, n)
for i := 0; i < b.N; i++ {
for j := range x {
x[j] = 0
}
clear(x)
}
})
}