JVM: Always invoke get()/charAt() in optimized for-loop over
CharSequence.withIndex(), even if element variable is unused in destructuring declaration. #KT-34779 Fixed
This commit is contained in:
committed by
Dmitry Petrov
parent
411dc5d60e
commit
f444702cf3
+5
-3
@@ -63,12 +63,14 @@ class CharSequenceWithIndexForLoopGenerator(
|
||||
}
|
||||
|
||||
override fun assignLoopParametersNextValues() {
|
||||
v.load(charSeqVar, charSeqType)
|
||||
v.load(indexVar, Type.INT_TYPE)
|
||||
v.invokeinterface("java/lang/CharSequence", "charAt", "(I)C")
|
||||
if (elementLoopComponent != null) {
|
||||
v.load(charSeqVar, charSeqType)
|
||||
v.load(indexVar, Type.INT_TYPE)
|
||||
v.invokeinterface("java/lang/CharSequence", "charAt", "(I)C")
|
||||
StackValue.local(elementLoopComponent.parameterVar, elementLoopComponent.parameterType)
|
||||
.store(StackValue.onStack(Type.CHAR_TYPE), v)
|
||||
} else {
|
||||
v.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user