aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-01-03 17:47:17 +0800
committerRunxi Yu <me@runxiyu.org>2025-01-03 17:47:17 +0800
commit074c8bd98db8be4ee3723d799a69c39b9edfd03a (patch)
tree5242457100b7b4de10311d3f1c1b5ab1213ef53c
parentAdd package descriptions (diff)
downloadgo-lindenii-common-074c8bd98db8be4ee3723d799a69c39b9edfd03a.tar.gz
go-lindenii-common-074c8bd98db8be4ee3723d799a69c39b9edfd03a.tar.zst
go-lindenii-common-074c8bd98db8be4ee3723d799a69c39b9edfd03a.zip
cmap: Update documentation
-rw-r--r--cmap/map.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/cmap/map.go b/cmap/map.go
index be00165..bfc0070 100644
--- a/cmap/map.go
+++ b/cmap/map.go
@@ -84,7 +84,7 @@ var expunged = unsafe.Pointer(new(any))
// An entry is a slot in the map corresponding to a particular key.
type entry[V comparable] struct {
- // p points to the interface{} value stored for the entry.
+ // p points to the value stored for the entry.
//
// If p == nil, the entry has been deleted, and either m.dirty == nil or
// m.dirty[key] is e.
@@ -191,9 +191,9 @@ func (e *entry[V]) tryCompareAndSwap(old V, new V) bool {
return false
}
- // Copy the interface after the first load to make this method more amenable
+ // Copy the pointer after the first load to make this method more amenable
// to escape analysis: if the comparison fails from the start, we shouldn't
- // bother heap-allocating an interface value to store.
+ // bother heap-allocating a pointer to store.
nc := new
for {
if atomic.CompareAndSwapPointer(&e.p, p, unsafe.Pointer(&nc)) {
@@ -273,7 +273,7 @@ func (e *entry[V]) tryLoadOrStore(i V) (actual V, loaded, ok bool) {
return *(*V)(p), true, true
}
- // Copy the interface after the first load to make this method more amenable
+ // Copy the pointer after the first load to make this method more amenable
// to escape analysis: if we hit the "load" path or the entry is expunged, we
// shouldn't bother heap-allocating.
ic := i
@@ -426,7 +426,7 @@ func (m *Map[K, V]) CompareAndSwap(key K, old, new V) (swapped bool) {
// The old value must be of a comparable type.
//
// If there is no current value for key in the map, CompareAndDelete
-// returns false (even if the old value is the nil interface value).
+// returns false (even if the old value is a nil pointer).
func (m *Map[K, V]) CompareAndDelete(key K, old V) (deleted bool) {
read := m.loadReadOnly()
e, ok := read.m[key]