Skip to content

lo.Mode and it.Mode inconsistencies #733

@NathanBaulch

Description

@NathanBaulch

#709 and #711 introduce inconsistencies that I'd like to address.

  1. Whilst implementing it.Mode I noticed that a new slice was being allocated (mode = []T{item}) each time a larger frequency is found. I addressed this by reusing the original slice (mode = append(mode[:0], item)). The issue from @d-enk recommended this change be applied to the lo.Mode slice version but the PR from @intojhanurag did not make this change.
  2. If truncating the capacity of return slices is deemed important (questionable!) then why would we apply it to this particular helper and not the 48 other helpers that return slices?
  3. There is no advantage to using the more verbose make([]T, 0) syntax that I'm aware of. See lint: use consistent short slice creation syntax #729.

My preference is to roll back #711 and replace with the simple slice reuse fix mentioned in item 1 above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions