KT-14258 Optimize accesses to properties defined into companion
- Use direct access to property defined into companion object when it is possible rather than always use an accessor to access the property. - Use direct access will speedup runtime performance. - Avoid to generate useless accessors for companion properties. Fix of https://youtrack.jetbrains.com/issue/KT-14258
This commit is contained in:
committed by
Alexander Udalov
parent
fd244be9ca
commit
d0ed0c4049
@@ -0,0 +1,28 @@
|
||||
// Checks that accessor methods are always used due to the overriding of the default setter of 'my' property.
|
||||
|
||||
class My {
|
||||
companion object {
|
||||
private var my: String = "OK"
|
||||
set(value) { field = value }
|
||||
}
|
||||
|
||||
fun getMyValue(): String {
|
||||
// INVOKESTATIC My$Companion.access$setMy$p
|
||||
my = "Overriden value"
|
||||
// GETSTATIC My.my
|
||||
return my
|
||||
}
|
||||
|
||||
// PUTSTATIC My.my into clinit
|
||||
// PUTSTATIC My.my into 'access$setMy$cp'
|
||||
// GETSTATIC My.my into 'access$getMy$cp'
|
||||
}
|
||||
|
||||
// 2 GETSTATIC My.my
|
||||
// 2 PUTSTATIC My.my
|
||||
// 0 INVOKESTATIC My\$Companion.access\$getMy\$p
|
||||
// 1 INVOKESTATIC My\$Companion.access\$setMy\$p
|
||||
// 1 INVOKESTATIC My.access\$setMy\$cp
|
||||
// 1 INVOKESTATIC My.access\$getMy\$cp
|
||||
// 1 INVOKESPECIAL My\$Companion.getMy
|
||||
// 1 INVOKESPECIAL My\$Companion.setMy
|
||||
Reference in New Issue
Block a user