diff --git a/src/cmd/go/internal/par/work.go b/src/cmd/go/internal/par/work.go index 5b6de9425a583f..3f1e69adfef0e8 100644 --- a/src/cmd/go/internal/par/work.go +++ b/src/cmd/go/internal/par/work.go @@ -189,10 +189,7 @@ func (c *Cache[K, V]) Get(key K) (V, bool) { // TODO(jayconrod): Delete this after the package cache clearing functions // in internal/load have been removed. func (c *Cache[K, V]) Clear() { - c.m.Range(func(key, value any) bool { - c.m.Delete(key) - return true - }) + c.m.Clear() } // Delete removes an entry from the map. It is safe to call Delete for an diff --git a/src/expvar/expvar.go b/src/expvar/expvar.go index ffe35d62f917a7..4f66848f1fe4cf 100644 --- a/src/expvar/expvar.go +++ b/src/expvar/expvar.go @@ -169,10 +169,7 @@ func (v *Map) Init() *Map { v.keysMu.Lock() defer v.keysMu.Unlock() v.keys = v.keys[:0] - v.m.Range(func(k, _ any) bool { - v.m.Delete(k) - return true - }) + v.m.Clear() return v } diff --git a/src/mime/type.go b/src/mime/type.go index 465ecf0d599ccb..6d4266929c350f 100644 --- a/src/mime/type.go +++ b/src/mime/type.go @@ -22,18 +22,11 @@ var ( extensions sync.Map // map[string][]string; slice values are append-only. ) -func clearSyncMap(m *sync.Map) { - m.Range(func(k, _ any) bool { - m.Delete(k) - return true - }) -} - // setMimeTypes is used by initMime's non-test path, and by tests. func setMimeTypes(lowerExt, mixExt map[string]string) { - clearSyncMap(&mimeTypes) - clearSyncMap(&mimeTypesLower) - clearSyncMap(&extensions) + mimeTypes.Clear() + mimeTypesLower.Clear() + extensions.Clear() for k, v := range lowerExt { mimeTypesLower.Store(k, v)