Optimize const vals by inlining them at use sites

#KT-11734 Fixed
 #KT-13570 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2016-12-05 12:02:52 +03:00
parent 8c1e165f18
commit 0134b8819b
28 changed files with 210 additions and 136 deletions
@@ -0,0 +1,17 @@
const val A = 10
private const val B = 20
object Constants {
const val C = 30
}
fun foo(state: Int) {
when (state) {
A -> return
B -> return
Constants.C -> return
else -> return
}
}
// 1 LOOKUPSWITCH
@@ -0,0 +1,20 @@
object Constants {
const val A = 30
const val B = 40
}
class ClassConstants {
companion object {
const val C = 50
}
}
fun foo(state: Int) {
when (state) {
Constants.A -> return
Constants.B -> return
ClassConstants.C -> return
else -> return
}
}
// 1 LOOKUPSWITCH
@@ -0,0 +1,16 @@
const val A = 10
private const val B = 20
object Constants {
const val C = 30
}
fun foo(state: Int) {
when (state) {
A -> return
B -> return
else -> return
}
}
// 1 LOOKUPSWITCH