Perform toImmutableList() less often.

This commit is contained in:
Benoit Marty 2025-10-17 11:42:21 +02:00 committed by Benoit Marty
parent 098a74435d
commit ff70722f8d

View file

@ -39,6 +39,7 @@ import io.element.android.libraries.featureflag.api.FeatureFlagService
import io.element.android.libraries.featureflag.api.FeatureFlags import io.element.android.libraries.featureflag.api.FeatureFlags
import io.element.android.libraries.featureflag.ui.model.FeatureUiModel import io.element.android.libraries.featureflag.ui.model.FeatureUiModel
import io.element.android.libraries.preferences.api.store.AppPreferencesStore import io.element.android.libraries.preferences.api.store.AppPreferencesStore
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -146,7 +147,7 @@ class DeveloperSettingsPresenter(
} }
return DeveloperSettingsState( return DeveloperSettingsState(
features = featureUiModels.toImmutableList(), features = featureUiModels,
cacheSize = cacheSize.value, cacheSize = cacheSize.value,
clearCacheAction = clearCacheAction.value, clearCacheAction = clearCacheAction.value,
rageshakeState = rageshakeState, rageshakeState = rageshakeState,
@ -165,7 +166,7 @@ class DeveloperSettingsPresenter(
@Composable @Composable
private fun createUiModels( private fun createUiModels(
enabledFeatures: SnapshotStateList<EnabledFeature>, enabledFeatures: SnapshotStateList<EnabledFeature>,
): List<FeatureUiModel> { ): ImmutableList<FeatureUiModel> {
return enabledFeatures.map { enabledFeature -> return enabledFeatures.map { enabledFeature ->
key(enabledFeature.feature.key) { key(enabledFeature.feature.key) {
remember(enabledFeature) { remember(enabledFeature) {
@ -178,7 +179,7 @@ class DeveloperSettingsPresenter(
) )
} }
} }
} }.toImmutableList()
} }
private fun CoroutineScope.updateEnabledFeature( private fun CoroutineScope.updateEnabledFeature(