diff options
author | Peter Collingbourne <pcc@google.com> | 2024-03-19 19:27:22 -0700 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2024-03-21 00:52:58 +0000 |
commit | 36cd880878a9804489557c29fa768647d665fbe0 (patch) | |
tree | 3c3884ef055a52de3687d2691f96cc9dc2c15236 /src/sync | |
parent | 7d4d71e52f0714c7990705f0fc56f9104761514e (diff) | |
download | go-36cd880878a9804489557c29fa768647d665fbe0.tar.gz go-36cd880878a9804489557c29fa768647d665fbe0.zip |
sync: name the Map.CompareAndSwap return value
The godoc for sync.Map.CompareAndSwap does not document the meaning
of its return value. Document it by giving it a name.
Change-Id: I50ad9c078a7885f5ce83489d66d138d491c35861
Reviewed-on: https://go-review.googlesource.com/c/go/+/572657
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/sync')
-rw-r--r-- | src/sync/map.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/sync/map.go b/src/sync/map.go index 7ae97bce1d..504410bc4b 100644 --- a/src/sync/map.go +++ b/src/sync/map.go @@ -393,7 +393,7 @@ func (m *Map) Swap(key, value any) (previous any, loaded bool) { // CompareAndSwap swaps the old and new values for key // if the value stored in the map is equal to old. // The old value must be of a comparable type. -func (m *Map) CompareAndSwap(key, old, new any) bool { +func (m *Map) CompareAndSwap(key, old, new any) (swapped bool) { read := m.loadReadOnly() if e, ok := read.m[key]; ok { return e.tryCompareAndSwap(old, new) @@ -404,7 +404,7 @@ func (m *Map) CompareAndSwap(key, old, new any) bool { m.mu.Lock() defer m.mu.Unlock() read = m.loadReadOnly() - swapped := false + swapped = false if e, ok := read.m[key]; ok { swapped = e.tryCompareAndSwap(old, new) } else if e, ok := m.dirty[key]; ok { |