Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Make MarkerState stable #235

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.ComposeNode
import androidx.compose.runtime.CompositionContext
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.currentComposer
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -81,13 +82,15 @@ public class MarkerState(
internal set

// The marker associated with this MarkerState.
internal var marker: Marker? = null
private val markerState: MutableState<Marker?> = mutableStateOf(null)
internal var marker: Marker?
get() = markerState.value
set(value) {
if (field == null && value == null) return
if (field != null && value != null) {
if (markerState.value == null && value == null) return
if (markerState.value != null && value != null) {
error("MarkerState may only be associated with one Marker at a time.")
}
field = value
markerState.value = value
}

/**
Expand Down