Closed hoc081098 closed 5 months ago
I am not really sure what is the optimization here. How are you ensuring that elements are not duplicated when using nonEmptySetOf
?
Furthermore, note that we are soon going to make arrow-2
the new main branch. There NonEmptySet
is defined differently, using an inline value class. It would be better if optimizations would be applied there, as we don't expect to make any further 1.2.x release.
I am not really sure what is the optimization here. How are you ensuring that elements are not duplicated when using
nonEmptySetOf
?
In constructor, we have used setOf(first) + rest
, it returns a Set.
Prev code: res (varargs === Array) -> toSet -> setOf(first) + res
uses 2 loops internally.
After code : res (varargs === Array) -> asList -> setOf(first) + res
uses 1 loops internally (because asList does not copy the array to List, but returns a read-only wrapper)
π
- Prev code:
res (varargs === Array) -> toSet -> setOf(first) + res
uses 2 loops internally.- After code :
res (varargs === Array) -> asList -> setOf(first) + res
uses 1 loops internally (because asList does not copy the array to List, but returns a read-only wrapper) π
I have changed the target branch to arrow-2
branch. @serras Please review it again π
@hoc081098 sorry for the unnecesary noise but, would it be possible for you to rebase these changes into the new main
? Otherwise it's impossible for us to merge properly this.
Iterable
(instead ofSet
).nonEmptySetOf
andtoNonEmptySetOrNull
.