Cache array length in for-in-array loop if possible
If the range expression is not a local variable (which can be updated in the loop body affecting loop behavior, see KT-21354), we can cache the array length, thus turning a for-in-array loop into a simple optimizable counter loop. #KT-21321 In Progress
This commit is contained in:
@@ -14537,6 +14537,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("forInArrayWithArrayPropertyUpdatedInLoopBody.kt")
|
||||
public void testForInArrayWithArrayPropertyUpdatedInLoopBody() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInArrayWithArrayPropertyUpdatedInLoopBody.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("forInArrayWithArrayVarUpdatedInLoopBody.kt")
|
||||
public void testForInArrayWithArrayVarUpdatedInLoopBody() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInArrayWithArrayVarUpdatedInLoopBody.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt")
|
||||
public void testForInRangeLiteralWithMixedTypeBounds() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt");
|
||||
|
||||
Reference in New Issue
Block a user