Open PierreEc opened 1 year ago
There is the same with kotlin with SequenceOf:
OS | OS version | Langage. |
---|---|---|
iOS/iPadOS/WatchOS/tvOS - Android | - | Swift / Kotlin |
ID | Title | Category | Sub-category |
---|---|---|---|
- | Environment | Optimized API |
Severity | Remediation Cost |
---|---|
Major | Minor |
Prefer lazysequences for optimize useless CPU cycles
Prefer lazysequences for optimize useless CPU cycles when you use operations such as map and filter
<p>Prefer lazysequences for optimize useless CPU cycles</p>
<p>
<a href="https://developer.apple.com/documentation/swift/lazysequence">Doc apple LazySequence</a>
<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/sequence-of.html">Doc android SequenceOf</a>
</p>
<p>
<img src="https://user-images.githubusercontent.com/18304803/230103031-275bdf34-8f45-45da-abc5-8f0dd97a72a6.png" />
</p>
This rule can now be implemented with the arrival of the Android Kotlin plugin @47tibo ;)
Interesting way of "activating" lazy in Swift 🙂 @olegoaer we can add this rule to kotlin, but it is a bit more complex than that.
In short, it depends on the type of the operators, their order in the chain and also the size of the collection.
Privilégier les lazysequences pour optimiser des cycles CPU inutiles
https://developer.apple.com/documentation/swift/lazysequence
Example:
With lazy: