cats
cats copied to clipboard
Optimize `distinct`/`distinctBy` implementations for non-empty collections
A follow up for #4608 (see my comment https://github.com/typelevel/cats/pull/4608#discussion_r1626935568).
For an example of a pretty well optimized implementation one could check out the corresponding methods in Chain
:
https://github.com/typelevel/cats/blob/930f25c544c787fe6703349090b5210a35249e70/core/src/main/scala/cats/data/Chain.scala#L797-L813 https://github.com/typelevel/cats/blob/930f25c544c787fe6703349090b5210a35249e70/core/src/main/scala/cats/data/Chain.scala#L826-L842