From 074c8bd98db8be4ee3723d799a69c39b9edfd03a Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Fri, 03 Jan 2025 17:47:17 +0800 Subject: [PATCH] cmap: Update documentation --- cmap/map.go | 10 +++++----- diff --git a/cmap/map.go b/cmap/map.go index be00165bee027aef1cdfcd734907bd4178ed3b98..bfc0070d96ad4694e25be187703178c8b825e791 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 @@ if p == nil || p == expunged || *(*V)(p) != old { // XXX 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 @@ if p != nil { 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 @@ // CompareAndDelete deletes the entry for key if its value is equal to old. // 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] -- 2.48.1