diff options
| author | Linnea Gräf <nea@nea.moe> | 2024-02-15 01:02:21 +0100 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2024-02-15 01:02:21 +0100 |
| commit | f6d8c3d8599957dc2f5c843d0e1e7243e84d4cb9 (patch) | |
| tree | 118de379d668f078213ddbb770285fff2ce91f47 /src/main/java/at/hannibal2/skyhanni/utils/const | |
| parent | c3018ca1a64d57dda614a639b04b4e52d2a85616 (diff) | |
| download | SkyHanni-feat/const.tar.gz SkyHanni-feat/const.tar.bz2 SkyHanni-feat/const.zip | |
Turns out value boxing is regretably still a thingfeat/const
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/const')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/const/Const.kt | 10 |
1 files changed, 3 insertions, 7 deletions
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 <reified U : T, T> Const<T>.tryCast(): Const<U>? = (unsafeMutable as? * mutable as long. The caller may never cast the returned instance to [MutableList]. */ fun <T> Const<List<T>>.liftList(): List<Const<T>> { - @Suppress("UNCHECKED_CAST") - // This cast is valid since List<T> and List<Const<T>> are always the same at runtime, guaranteed by `@JvmInline` - return unsafeMutable as List<Const<T>> + return unsafeMutable.map(Const.Companion::newUnchecked) } /** @@ -90,8 +88,6 @@ fun <T> Const<List<T>>.liftList(): List<Const<T>> { * either constructed directly as a [List] or if it originally comes from a [MutableList], mutations operations on this * instance are never used. */ -fun <T> List<Const<T>>.unliftList(): Const<List<T>> { - @Suppress("UNCHECKED_CAST") - // This cast is valid since List<T> and List<Const<T>> are always the same at runtime, guaranteed by `@JvmInline` - return Const.newUnchecked(this as List<T>) +fun <T> List<Const<T>>.liftConst(): Const<List<T>> { + return Const.newUnchecked(this.map { it.unsafeMutable }) } |
