mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 08:31:29 +00:00
KT-22334 Specialized loops using range such as integer..array.size-1
- Into PrimitiveNumberRangeLiteralRangeValue modifies how bounded value are created by checking if the high bound range can be modified to be exclusive instead of inclusive such as the generated code will be optimized. - Add black box tests checking that the specialization does not fail on any kind of arrays. - Add a bytecode test checking that the code is correctly optimized. Fix of https://youtrack.jetbrains.com/issue/KT-22334
This commit is contained in:
committed by
Dmitry Petrov
parent
8c8caa4707
commit
8676ca34d7
12
compiler/testData/codegen/bytecodeText/forLoop/forInRangeSpecializedToUntil.kt
vendored
Normal file
12
compiler/testData/codegen/bytecodeText/forLoop/forInRangeSpecializedToUntil.kt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fun test(): Int {
|
||||
val intArray = intArrayOf(1, 2, 3)
|
||||
var sum = 0
|
||||
for (i in 0..intArray.size-1) {
|
||||
sum += intArray[i]
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
// 1 IF_ICMPGE
|
||||
// 0 IF_ICMPGT
|
||||
// 0 IF_ICMPEQ
|
||||
Reference in New Issue
Block a user