dimsuz
06/28/2023, 2:44 PM@Immutable
. This is the quote from Chris Banes' article:
An object that is immutable means that ‘all publicly accessible properties and fields will not change after the instance is constructed’. This characteristic means that Compose can detect ‘changes’ between two instances very easily.But how exactly does compose "detect changes"? If function parameter is immutable, what compose will do with it? referentially compare prev/next values? run
prev.equals(next)
? I can't seem to find any info about this in docs, most places say that "this enables some optimizations".Zach Klippenstein (he/him) [MOD]
06/28/2023, 2:47 PMZach Klippenstein (he/him) [MOD]
06/28/2023, 2:47 PMWhen all types passed as parameters to afunction are marked as stable then the parameter values are compared for equality based on positional memoization and the call is skipped if all the values are the equal to the previous call.Composable
dimsuz
06/28/2023, 3:42 PMdewildte
06/28/2023, 4:36 PMvar thing by mutableStateOf("stuff")
considered @Stable
or @Immutable
because the delegate property is not changing?dewildte
06/28/2023, 4:40 PM@Stable
is true by not @Immutable
.dewildte
06/28/2023, 4:42 PM@Immutable
has some serious perfomance implications.shikasd
06/28/2023, 7:09 PMshikasd
06/28/2023, 7:14 PMThanks! "based on positional memoization" bit is still unclear to me, afaik positional memoization is about composable function calls and position of their emissions in the tree, but how is it related to the function parameters?... (I'll need to read more about this I guess)
If all parameters are stable, they are memoized whenever a function is called If the function is called again in that position, parameter values are compared and function can skip if values are the same
shikasd
06/28/2023, 7:15 PMshikasd
06/28/2023, 7:16 PMdimsuz
06/29/2023, 10:10 AMequals
?shikasd
06/29/2023, 10:47 AMdimsuz
06/29/2023, 11:30 AM