1
0
mirror of https://github.com/golang/go synced 2024-11-22 16:44:54 -07:00

sync: update doc for Map.Clear

This commit is contained in:
Jes Cok 2024-02-02 00:20:38 +08:00
parent 5b6cd3d0cb
commit 818b95528f

View File

@ -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