aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorJes Cok <xigua67damn@gmail.com>2023-07-25 23:10:34 +0000
committerGopher Robot <gobot@golang.org>2023-07-27 22:07:13 +0000
commit3bc28402fae2a1646e4d2756344b5eb34994d25f (patch)
treea7b1cb6fe83f489e038e9a11204eb0b9795ee802 /src/testing
parent1c10d743eaff174f08e48dff85f64ade0b92425c (diff)
downloadgo-3bc28402fae2a1646e4d2756344b5eb34994d25f.tar.gz
go-3bc28402fae2a1646e4d2756344b5eb34994d25f.zip
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 <iant@google.com> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/benchmark.go4
-rw-r--r--src/testing/match.go4
2 files changed, 2 insertions, 6 deletions
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) {