Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comment about using efficient map clear with Go 1.20 as base #5569

Merged
merged 2 commits into from
Feb 28, 2025
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
7 changes: 3 additions & 4 deletions internal/async/map_migratedfynedo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ package async

// Map is a generic wrapper around [sync.Map].
type Map[K any, V any] struct {
// once go1.20 is base, can use map[K]V
// with K being Comparable instead of any
// (CanvasObject, etc aren't Comparable for go1.19)
// Use "comparable" as type constraint and map[K]V as the inner type
// once Go 1.20 is our minimum version so interfaces can be used as keys.
m map[any]V
}

Expand Down Expand Up @@ -69,5 +68,5 @@ func (m *Map[K, V]) Store(key K, value V) {

// Clear removes all entries from the map.
func (m *Map[K, V]) Clear() {
m.m = make(map[any]V)
m.m = make(map[any]V) // Use range-and-delete loop once Go 1.20 is the minimum version.
}
Loading