]> Cypherpunks repositories - gostls13.git/commitdiff
sync: update doc for Map.Clear
authorJes Cok <xigua67damn@gmail.com>
Thu, 1 Feb 2024 16:28:07 +0000 (16:28 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 1 Feb 2024 19:34:02 +0000 (19:34 +0000)
Change-Id: I9bcc5c82321cbc93f1c7aafd1dadf4f6b862ccbd
GitHub-Last-Rev: 818b95528f6beb6178b385953b49fbfbaeb31a82
GitHub-Pull-Request: golang/go#65429
Reviewed-on: https://go-review.googlesource.com/c/go/+/560396
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/sync/map.go

index 1f26cdd8bb56cd2b8a9491f41919c175a0ce1fb6..ec5ed29ae58daf202c3fa9ccc1309470409ec721 100644 (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