perf: mark Compose state types as @Immutable
Compose compiler reports showed DownloadState's sealed root as Uncertain and DownloadProgressState/SettingsUiState as runtime stability, so skippability checks were deferred to runtime. The annotations make them compile-time stable and turn any future mutable field into an explicit contract break.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package com.example.research
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@Immutable
|
||||
sealed interface DictionaryStatus {
|
||||
data object Unknown : DictionaryStatus
|
||||
data object Checking : DictionaryStatus
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.example.research.core.domain.model
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
/**
|
||||
* Snapshot of an ongoing indexing operation.
|
||||
*
|
||||
@@ -11,6 +13,7 @@ import kotlin.math.roundToInt
|
||||
* [perFileProgress] is kept for diagnostics; callers should prefer
|
||||
* [progress] / [progressPercent].
|
||||
*/
|
||||
@Immutable
|
||||
data class IndexingProgress(
|
||||
val currentFile: String = "",
|
||||
val currentIndex: Int = 0,
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
package com.example.research.feature.download.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@Immutable
|
||||
sealed class DownloadState {
|
||||
data object Idle : DownloadState()
|
||||
data object Loading : DownloadState()
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.example.research.ui.settings
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@Immutable
|
||||
sealed interface ImportState {
|
||||
data object Idle : ImportState
|
||||
data class Importing(val progress: Float) : ImportState
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.example.research.ui.settings
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.example.research.core.domain.model.AppTheme
|
||||
import com.example.research.core.domain.model.Dictionary
|
||||
import com.example.research.core.domain.model.DictionarySource
|
||||
@@ -8,6 +9,7 @@ import com.example.research.core.domain.model.IndexingProgress
|
||||
import com.example.research.DictionaryStatus
|
||||
import com.example.research.feature.download.model.DownloadState
|
||||
|
||||
@Immutable
|
||||
data class SettingsUiState(
|
||||
val theme: AppTheme = AppTheme.SYSTEM,
|
||||
val language: String = "system",
|
||||
|
||||
Reference in New Issue
Block a user