From 4b810c6ffb673bcd6cb380a787ed4c5d62eff5a0 Mon Sep 17 00:00:00 2001 From: Milarin Date: Thu, 15 Feb 2024 16:38:27 +0100 Subject: [PATCH] removed DoUnsafe --- map.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/map.go b/map.go index 941dcbf..a8d0b59 100644 --- a/map.go +++ b/map.go @@ -96,24 +96,8 @@ func (m *Map[K, V]) Values() []V { // Do calls f with the underlying primitive map. // Be aware that this locks m for write access // so Do can be used for reading as well as modifiying m. -// After f returns, the map will be shallow-copied in order to prevent -// clueless programmers from storing the map and modifying it afterwards. -// If you need that little bit of optimization, use DoUnsafe instead func (m *Map[K, V]) Do(f func(m map[K]V)) { m.mutex.Lock() defer m.mutex.Unlock() f(m.data) - - nm := map[K]V{} - for key, value := range m.data { - nm[key] = value - } - m.data = nm -} - -// DoUnsafe behaves like Do but does not create a shallow-copy of m -func (m *Map[K, V]) DoUnsafe(f func(m map[K]V)) { - m.mutex.Lock() - defer m.mutex.Unlock() - f(m.data) }