From 3bc28402fae2a1646e4d2756344b5eb34994d25f Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Tue, 25 Jul 2023 23:10:34 +0000 Subject: all: use built-in clear to clear maps Change-Id: I7f4ac72fe3230d8b7486fab0c925015cefcbe355 GitHub-Last-Rev: 54455839b674f980fb6c3afceb433db4833d340e GitHub-Pull-Request: golang/go#61544 Reviewed-on: https://go-review.googlesource.com/c/go/+/512376 Reviewed-by: Ian Lance Taylor Run-TryBot: Keith Randall Reviewed-by: Bryan Mills Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor TryBot-Result: Gopher Robot --- src/testing/benchmark.go | 4 +--- src/testing/match.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'src/testing') diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go index be9b87f80b..0f4fc3d930 100644 --- a/src/testing/benchmark.go +++ b/src/testing/benchmark.go @@ -151,9 +151,7 @@ func (b *B) ResetTimer() { // Pre-size it to make more allocation unlikely. b.extra = make(map[string]float64, 16) } else { - for k := range b.extra { - delete(b.extra, k) - } + clear(b.extra) } if b.timerOn { runtime.ReadMemStats(&memStats) diff --git a/src/testing/match.go b/src/testing/match.go index 92b7dc622d..84804dc2ec 100644 --- a/src/testing/match.go +++ b/src/testing/match.go @@ -119,9 +119,7 @@ func (m *matcher) fullName(c *common, subname string) (name string, ok, partial func (m *matcher) clearSubNames() { m.mu.Lock() defer m.mu.Unlock() - for key := range m.subNames { - delete(m.subNames, key) - } + clear(m.subNames) } func (m simpleMatch) matches(name []string, matchString func(pat, str string) (bool, error)) (ok, partial bool) { -- cgit v1.3-6-g1900