]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make use of builtin clear in tests
authorJes Cok <xigua67damn@gmail.com>
Thu, 28 Mar 2024 04:50:04 +0000 (12:50 +0800)
committerGopher Robot <gobot@golang.org>
Fri, 29 Mar 2024 16:41:12 +0000 (16:41 +0000)
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>

src/runtime/hash_test.go
src/runtime/memmove_test.go

index 08672dbe8af521a6a22c06202a01010cb537f70c..77f916797f3ea25ff97c374984e1a9e9ddedd9bc 100644 (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)
index 0a97e39d3e2c81e9249067ae65c22fdd94decf52..6550c759d637362953bd899595e3ce0818dd098c 100644 (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)
                }
        })
 }