From f6d8c3d8599957dc2f5c843d0e1e7243e84d4cb9 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 15 Feb 2024 01:02:21 +0100 Subject: Turns out value boxing is regretably still a thing --- src/main/java/at/hannibal2/skyhanni/utils/const/Const.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/const/Const.kt b/src/main/java/at/hannibal2/skyhanni/utils/const/Const.kt index 30d8ef0c6..26e568431 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/const/Const.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/const/Const.kt @@ -80,9 +80,7 @@ inline fun Const.tryCast(): Const? = (unsafeMutable as? * mutable as long. The caller may never cast the returned instance to [MutableList]. */ fun Const>.liftList(): List> { - @Suppress("UNCHECKED_CAST") - // This cast is valid since List and List> are always the same at runtime, guaranteed by `@JvmInline` - return unsafeMutable as List> + return unsafeMutable.map(Const.Companion::newUnchecked) } /** @@ -90,8 +88,6 @@ fun Const>.liftList(): List> { * either constructed directly as a [List] or if it originally comes from a [MutableList], mutations operations on this * instance are never used. */ -fun List>.unliftList(): Const> { - @Suppress("UNCHECKED_CAST") - // This cast is valid since List and List> are always the same at runtime, guaranteed by `@JvmInline` - return Const.newUnchecked(this as List) +fun List>.liftConst(): Const> { + return Const.newUnchecked(this.map { it.unsafeMutable }) } -- cgit