From 818b95528f6beb6178b385953b49fbfbaeb31a82 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Fri, 2 Feb 2024 00:20:38 +0800 Subject: [PATCH] sync: update doc for Map.Clear --- src/sync/map.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sync/map.go b/src/sync/map.go index 1f26cdd8bb5..ec5ed29ae58 100644 --- a/src/sync/map.go +++ b/src/sync/map.go @@ -155,7 +155,7 @@ func (m *Map) Store(key, value any) { _, _ = m.Swap(key, value) } -// Clear deletes all the keys. +// Clear deletes all the entries, resulting in an empty Map. func (m *Map) Clear() { read := m.loadReadOnly() if len(read.m) == 0 && !read.amended { @@ -172,7 +172,8 @@ func (m *Map) Clear() { } clear(m.dirty) - m.misses = 0 // Don't immediately promote the newly-cleared dirty map on the next operation + // Don't immediately promote the newly-cleared dirty map on the next operation. + m.misses = 0 } // tryCompareAndSwap compare the entry with the given old value and swaps