Avoid primitive boxing for 'boxed == primitive' if possible

This makes sense for non-floating-point primitive type
(boolean, char, byte, short, int, long):
floating-point types use specialized versions of 'areEqual'.
This commit is contained in:
Dmitry Petrov
2017-07-13 14:15:09 +03:00
parent 275c758da1
commit 8aacddb9f0
17 changed files with 781 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
fun testBoolean1(a: Boolean?, b: Boolean) = a == b
fun testBoolean2(a: Boolean?, b: Boolean) = a != b
fun testChar1(a: Char?, b: Char) = a == b
fun testChar2(a: Char?, b: Char) = a != b
fun testByte1(a: Byte?, b: Byte) = a == b
fun testByte2(a: Byte?, b: Byte) = a != b
fun testShort1(a: Short?, b: Short) = a == b
fun testShort2(a: Short?, b: Short) = a != b
fun testInt1(a: Int?, b: Int) = a == b
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