perf(about): parse the license catalog with decodeFromStream

Stream the bundled license catalog straight into the JSON decoder
instead of buffering the whole resource as a string first, halving
parse time and peak allocation when the About screen loads.
This commit is contained in:
OneWay committed 2026-10-05 05:18:57 +08:00
1 parent 9b6a34b607
commit 9de47c7f0f
1 file changed
+2 -2
@@ -5,6 +5,7 @@ import androidx.annotation.RawRes
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.decodeFromStream
@Serializable @Serializable
internal data class AboutLibrariesData( internal data class AboutLibrariesData(
@@ -76,6 +77,5 @@ internal object AboutLibrariesParser {
fun read(context: Context, @RawRes resourceId: Int): AboutLibrariesData = fun read(context: Context, @RawRes resourceId: Int): AboutLibrariesData =
context.resources.openRawResource(resourceId) context.resources.openRawResource(resourceId)
.bufferedReader() .use { stream -> json.decodeFromStream(stream) }
.use { reader -> json.decodeFromString(reader.readText()) }
} }