You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rule or changes you're looking for might have already been suggested!
Please search in the issues before creating a new one.
Expected Behavior of the rule
When operations such as map, filter, etc. are chained on an Iterable or Collection, the rule would say that asSequence() should be called before the operations to optimize performance.
Context
Kotlin provides operations like map, filter, etc. directory on Collection and Iterable objects through extension methods. The problem with using these is that if you chain the methods e.g. do a filter then a map multiple iterations are done over the collection/iterable.
However, if a Kotlin sequence is used then only a single iteration is done over the data as the operations are composed and lazily evaluated in a similar way to how Java streams operate https://kotlinlang.org/docs/sequences.html talks about this
The text was updated successfully, but these errors were encountered:
mjsztainbok
changed the title
A rule for when multiple collection or iterable operations are used to suggest that a sequence be used instead
A rule for when multiple collection or iterable operations are chained to suggest that a sequence be used instead
May 18, 2022
If @mjsztainbok don't want to, then I sure would love to try 🙂 I already started looking a bit into it, but can step aside if @mjsztainbok would prefer looking at it
The rule or changes you're looking for might have already been suggested!
Please search in the issues before creating a new one.
Expected Behavior of the rule
When operations such as
map
,filter
, etc. are chained on anIterable
orCollection
, the rule would say thatasSequence()
should be called before the operations to optimize performance.Context
Kotlin provides operations like
map
,filter
, etc. directory onCollection
andIterable
objects through extension methods. The problem with using these is that if you chain the methods e.g. do afilter
then amap
multiple iterations are done over the collection/iterable.However, if a Kotlin sequence is used then only a single iteration is done over the data as the operations are composed and lazily evaluated in a similar way to how Java streams operate
https://kotlinlang.org/docs/sequences.html talks about this
The text was updated successfully, but these errors were encountered: