From cc23193e3836008ec60e402ded99764bfb3e3769 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 10 Jun 2026 09:17:52 -0700 Subject: [PATCH] Remove dead internal class ClearableSynchronizedPool Summary: X-link: https://github.com/facebook/react-native/pull/57135 `ClearableSynchronizedPool` (an `internal` Kotlin class in `ReactAndroid/.../common/`) was a variant of androidx `Pools.SynchronizedPool` adding a `clear()` method, but it was never instantiated or referenced anywhere. The live event pools (`OnLayoutEvent`, `PointerEvent`, `TouchEvent`, `ScrollEvent`) use androidx `SynchronizedPool` directly. This removes the orphaned class. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D108012905 fbshipit-source-id: d5972b4c47d054310c8b7803482fa4e6b7a9928e --- .../react/common/ClearableSynchronizedPool.kt | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/ClearableSynchronizedPool.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/ClearableSynchronizedPool.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/ClearableSynchronizedPool.kt deleted file mode 100644 index 16e79301734..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/ClearableSynchronizedPool.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.common - -import androidx.core.util.Pools.Pool - -/** - * Like [androidx.core.util.Pools.SynchronizedPool] with the option to clear the pool (e.g. on - * memory pressure). - */ -internal class ClearableSynchronizedPool(maxSize: Int) : Pool { - - private val pool: Array = arrayOfNulls(maxSize) - private var size = 0 - - @Synchronized - @Suppress("UNCHECKED_CAST", "KotlinGenericsCast") - override fun acquire(): T? { - if (size == 0) { - return null - } - size-- - val lastIndex = size - val toReturn = pool[lastIndex] as T - pool[lastIndex] = null - return toReturn - } - - @Synchronized - override fun release(instance: T): Boolean { - if (size == pool.size) { - return false - } - pool[size] = instance - size++ - return true - } - - @Synchronized - fun clear(): Unit { - for (i in 0 until size) { - pool[i] = null - } - size = 0 - } -}