mirror of
https://github.com/golang/go
synced 2024-10-14 03:43:28 +00:00
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:
parent
8f59b28fb3
commit
2830d5457e
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue