Ji Sungbin
06/25/2022, 5:40 AMinvalidateGroupsWithKey(key: Int)
function in SlotTable only used for testing? I followed the final call of invalidateGroupsWithKey and arrived at the invalidateGroupsWithKey function with @TestOnly attached, and this function is not used. I figured out that the only use case of the findEffectiveRecomposeScope(group: Int)
function, which is i think an important function of SlotTable, is invalidateGroupsWithKey, and I wanted to know where invalidateGroupsWithKey is called.
@TestOnly
fun invalidateGroupsWithKey(key: Int) = HotReloader.invalidateGroupsWithKey(key)
And in the process of reaching final TestOnly function, I saw a function like the one below.
fun invalidateGroupsWithKey(key: Int) {
val compositions: List<ControlledComposition> = synchronized(stateLock) {
knownCompositions.toMutableList()
}
compositions
.fastMapNotNull { it as? CompositionImpl }
.fastForEach { it.invalidateGroupsWithKey(key) }
}
}
knownCompositions
is already a MutableList, but why change MutableList to MutableList?Albert Chang
06/25/2022, 1:05 PMtoMutableList()
is to create a copy of the original list.Ji Sungbin
06/25/2022, 1:10 PMtoMutableList()
too!