mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
Optimize for-in-string loops
For-in-string loop can be generated using specialized 'length' and 'charAt' method calls, and with cached string length. Note that update of the string variable in loop body doesn't affect loop execution semantics. #KT-21322 Fixed Target versions 1.2.20
This commit is contained in:
15
compiler/testData/codegen/bytecodeText/forLoop/forInStringSpecialized.kt
vendored
Normal file
15
compiler/testData/codegen/bytecodeText/forLoop/forInStringSpecialized.kt
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test() {
|
||||
var s = ""
|
||||
for (c in "testString") {
|
||||
s += c
|
||||
}
|
||||
}
|
||||
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 nextChar
|
||||
// 0 INVOKEINTERFACE
|
||||
// 1 ISTORE 4
|
||||
// 1 ILOAD 4
|
||||
Reference in New Issue
Block a user