mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-13 14:43:19 +00:00
syncs: delete Map.Range, update callers to iterators
Updates #11038 Change-Id: I2819fed896cc4035aba5e4e141b52c12637373b1 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
2cadb80fb2
commit
c763b7a7db
@@ -253,22 +253,6 @@ func (m *Map[K, V]) Delete(key K) {
|
||||
delete(m.m, key)
|
||||
}
|
||||
|
||||
// Range iterates over the map in an undefined order calling f for each entry.
|
||||
// Iteration stops if f returns false. Map changes are blocked during iteration.
|
||||
// A read lock is held for the entire duration of the iteration.
|
||||
// Use the [WithLock] method instead to mutate the map during iteration.
|
||||
//
|
||||
// Deprecated: Use [All], [Keys], or [Values] instead.
|
||||
func (m *Map[K, V]) Range(f func(key K, value V) bool) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
for k, v := range m.m {
|
||||
if !f(k, v) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keys iterates over all keys in the map in an undefined order.
|
||||
// A read lock is held for the entire duration of the iteration.
|
||||
// Use the [WithLock] method instead to mutate the map during iteration.
|
||||
|
Reference in New Issue
Block a user