Skip to content

Commit

Permalink
runner: preallocate memory (#7990)
Browse files Browse the repository at this point in the history
`toList()` knows upfront the number of tags that will end up in the list. Preallocating the exact size upfront reduces memory and GC operations.
  • Loading branch information
florianl authored Aug 13, 2024
1 parent 0263e7b commit b5ad83d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hack/deployer/runner/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
// toList transforms a map into a slice of string where each element corresponds
// to an entry in the map represented in the form 'key=value'.
func toList(m map[string]string) []string {
l := []string{}
l := make([]string, 0, len(m))
for k, v := range m {
l = append(l, fmt.Sprintf("%s=%s", k, v))
}
Expand Down

0 comments on commit b5ad83d

Please sign in to comment.