Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mightymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ func (m *Map[K, V]) Has(ctx context.Context, key K) (ok bool) {
// Store inserts or updates a value in the map for the given key.
// If allowOverwrite is false, it will only insert if the key doesn't exist.
func (m *Map[K, V]) Store(ctx context.Context, key K, value V) {
if _, ok := m.storage.Load(ctx, key); !ok || m.allowOverwrite {
if m.allowOverwrite {
m.storage.Store(ctx, key, value)
} else if _, ok := m.storage.Load(ctx, key); !ok {
m.storage.Store(ctx, key, value)
}
}
Expand Down