Skip to content

Commit 95feba8

Browse files
committed
All we ever needed was @synchronized
1 parent b2ad8e8 commit 95feba8

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/internal/interop/InteropUiBlockListener.kt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,27 @@ internal class InteropUIBlockListener : UIManagerListener {
4141
@Synchronized
4242
override fun willMountItems(uiManager: UIManager) {
4343
if (beforeUIBlocks.isEmpty()) {
44-
return
45-
}
46-
// avoid ConcurrentModificationException by iterating over a copy
47-
val snapshot = ArrayList(beforeUIBlocks)
48-
beforeUIBlocks.clear()
49-
if (uiManager is UIBlockViewResolver) {
50-
snapshot.forEach { block ->
51-
block.execute(uiManager)
44+
return
45+
}
46+
beforeUIBlocks.forEach {
47+
if (uiManager is UIBlockViewResolver) {
48+
it.execute(uiManager)
5249
}
5350
}
51+
beforeUIBlocks.clear()
5452
}
5553

5654
@Synchronized
5755
override fun didMountItems(uiManager: UIManager) {
5856
if (afterUIBlocks.isEmpty()) {
59-
return
60-
}
61-
// avoid ConcurrentModificationException by iterating over a copy
62-
val snapshot = ArrayList(afterUIBlocks)
63-
afterUIBlocks.clear()
64-
if (uiManager is UIBlockViewResolver) {
65-
snapshot.forEach { block ->
66-
block.execute(uiManager)
57+
return
58+
}
59+
afterUIBlocks.forEach {
60+
if (uiManager is UIBlockViewResolver) {
61+
it.execute(uiManager)
6762
}
6863
}
64+
afterUIBlocks.clear()
6965
}
7066

7167
override fun didDispatchMountItems(uiManager: UIManager) = didMountItems(uiManager)

0 commit comments

Comments
 (0)