diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/YogaNodePool.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/YogaNodePool.java deleted file mode 100644 index 1af237ec325..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/YogaNodePool.java +++ /dev/null @@ -1,33 +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.uimanager; - -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.react.common.ClearableSynchronizedPool; -import com.facebook.yoga.YogaNode; - -/** Static holder for a recycling pool of YogaNodes. */ -@Nullsafe(Nullsafe.Mode.LOCAL) -class YogaNodePool { - - private static final Object sInitLock = new Object(); - private static ClearableSynchronizedPool sPool; - - public static ClearableSynchronizedPool get() { - if (sPool != null) { - return sPool; - } - - synchronized (sInitLock) { - if (sPool == null) { - sPool = new ClearableSynchronizedPool<>(1024); - } - return sPool; - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/YogaNodePool.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/YogaNodePool.kt new file mode 100644 index 00000000000..d76399e8f83 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/YogaNodePool.kt @@ -0,0 +1,20 @@ +/* + * 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.uimanager + +import com.facebook.react.common.ClearableSynchronizedPool +import com.facebook.yoga.YogaNode + +/** Static holder for a recycling pool of YogaNodes. */ +internal object YogaNodePool { + + private val pool: ClearableSynchronizedPool by + lazy(LazyThreadSafetyMode.SYNCHRONIZED) { ClearableSynchronizedPool(1024) } + + @JvmStatic fun get(): ClearableSynchronizedPool = pool +}