mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Prefer compact bytecode for primitive/object comparisons with Boolean
'java.lang.Boolean#valueOf' doesn't allocate new objects (it uses pre-allocated singletons for 'true' and 'false').
This commit is contained in:
@@ -16,11 +16,11 @@ fun testInt2(a: Int?, b: Int) = a != b
|
||||
fun testLong1(a: Long?, b: Long) = a == b
|
||||
fun testLong2(a: Long?, b: Long) = a != b
|
||||
|
||||
// 2 booleanValue
|
||||
// 2 charValue
|
||||
// 2 byteValue
|
||||
// 2 shortValue
|
||||
// 2 intValue
|
||||
// 2 longValue
|
||||
// 0 valueOf
|
||||
// 0 areEqual
|
||||
// 2 valueOf
|
||||
// 2 Boolean.valueOf
|
||||
// 2 areEqual
|
||||
@@ -16,11 +16,11 @@ fun testInt2(a: Int, b: Int?) = a != b
|
||||
fun testLong1(a: Long, b: Long?) = a == b
|
||||
fun testLong2(a: Long, b: Long?) = a != b
|
||||
|
||||
// 2 booleanValue
|
||||
// 2 charValue
|
||||
// 2 byteValue
|
||||
// 2 shortValue
|
||||
// 2 intValue
|
||||
// 2 longValue
|
||||
// 0 valueOf
|
||||
// 0 areEqual
|
||||
// 2 valueOf
|
||||
// 2 Boolean.valueOf
|
||||
// 2 areEqual
|
||||
@@ -16,11 +16,11 @@ fun testInt2(a: Int, b: Any?) = a != b
|
||||
fun testLong1(a: Long, b: Any?) = a == b
|
||||
fun testLong2(a: Long, b: Any?) = a != b
|
||||
|
||||
// 2 booleanValue
|
||||
// 2 charValue
|
||||
// 2 byteValue
|
||||
// 2 shortValue
|
||||
// 2 intValue
|
||||
// 2 longValue
|
||||
// 0 valueOf
|
||||
// 0 areEqual
|
||||
// 2 valueOf
|
||||
// 2 Boolean.valueOf
|
||||
// 2 areEqual
|
||||
Reference in New Issue
Block a user