Skip to content

Commit

Permalink
Correct slice capacity initialisation intent
Browse files Browse the repository at this point in the history
len(unique) is always 0 as it's a map; intent is to initialise the slice with capacity that assumes there are no duplicates/empty elements.

Avoid scanning/linting tools from continuing to suggest useless changes that have no effect.

Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
  • Loading branch information
chadlwilson committed Oct 3, 2024
1 parent c42ebff commit 394fb7b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func appendTags(s []string, tags *gauge.Tags) []string {

func uniqueNonEmptyElementsOf(input []string) []string {
unique := make(map[string]bool, len(input))
us := make([]string, len(unique))
us := make([]string, 0, len(input))
for _, elem := range input {
if len(elem) != 0 && !unique[elem] {
us = append(us, elem)
Expand Down

0 comments on commit 394fb7b

Please # to comment.