Call chain --> Sequence: introduce "call chain length" parameter
#KT-26571 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
a43be4cbe8
commit
920c200693
+3
-1
@@ -1,5 +1,7 @@
|
||||
// PROBLEM: Call chain on collection could be converted into 'Sequence' to increase performance
|
||||
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(): List<Int> {
|
||||
return listOf(1, 2, 3).<caret>filter { it > 1 }.map { it * 2 }
|
||||
return listOf(1, 2, 3).<caret>filter { it > 1 }.map { it * 2 }.map { it * 3 }.map { it * 4 }.map { it * 5 }
|
||||
}
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
// PROBLEM: Call chain on collection could be converted into 'Sequence' to increase performance
|
||||
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(): List<Int> {
|
||||
return listOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.toList()
|
||||
return listOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.map { it * 3 }.map { it * 4 }.map { it * 5 }.toList()
|
||||
}
|
||||
+3
@@ -1,7 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(list: List<Int>): List<Int> {
|
||||
return list
|
||||
.filter<caret> { it > 1 }
|
||||
.map { it * 2 }
|
||||
.map { it * 3 }
|
||||
.map { it * 4 }
|
||||
}
|
||||
+3
@@ -1,3 +1,4 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(list: List<Int>): List<Int> {
|
||||
@@ -5,5 +6,7 @@ fun test(list: List<Int>): List<Int> {
|
||||
.asSequence()
|
||||
.filter { it > 1 }
|
||||
.map { it * 2 }
|
||||
.map { it * 3 }
|
||||
.map { it * 4 }
|
||||
.toList()
|
||||
}
|
||||
Reference in New Issue
Block a user