Skip to content

Commit

Permalink
fix: set map capacity in Associate (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatolyRugalev committed Dec 9, 2022
1 parent 470adbe commit 0ed7b6e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion slice.go
Expand Up @@ -345,7 +345,7 @@ func KeyBy[K comparable, V any](collection []V, iteratee func(item V) K) map[K]V
// The order of keys in returned map is not specified and is not guaranteed to be the same from the original array.
// Play: https://go.dev/play/p/WHa2CfMO3Lr
func Associate[T any, K comparable, V any](collection []T, transform func(item T) (K, V)) map[K]V {
result := make(map[K]V)
result := make(map[K]V, len(collection))

for _, t := range collection {
k, v := transform(t)
Expand Down

0 comments on commit 0ed7b6e

Please sign in to comment.