louiscad
12/18/2017, 3:04 PMval thisIsAByte: Byte = getValueFromMagic()
when (thisIsAByte) {
0x00.toByte() -> LOCKED
0x01.toByte() -> UNLOCKED
0x02.toByte() -> UNLOCKED_AND_AUTO_RELOCK_DISABLED
else -> throw IllegalStateException("Unexpected value for lockState: $it")
}
Hope we will soon be able to get rid of the toByte()
callsgildor
12/18/2017, 3:08 PMthisIsAByte.toInt()
louiscad
12/18/2017, 4:21 PMgildor
12/18/2017, 4:50 PMbyte
is just int
in bytecode, and actually even less efficient, because JVM adds value overflow checks for some operations. The only case when byte is more efficient is arraysbyte
(excluding arrays/buffers)