Skip to content

Commit 8d0a42c

Browse files
sammy-SCpull[bot]
authored andcommitted
Clean up constructor in FabricMountingManager
Summary: changelog: [internal] Make all feature flags `const` and initialise them as ivars. Also makes the class final and removes virtualised destructor since it is not needed. Reviewed By: ShikaSD Differential Revision: D34549013 fbshipit-source-id: 2b326bc5b6c1dd6d89c2fb9c671bda6da669fa76
1 parent 51d5c4f commit 8d0a42c

File tree

2 files changed

+32
-35
lines changed

2 files changed

+32
-35
lines changed

ReactAndroid/src/main/java/com/facebook/react/fabric/jni/FabricMountingManager.cpp

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ using namespace facebook::jni;
2828
namespace facebook {
2929
namespace react {
3030

31+
static bool doesUseOverflowInset() {
32+
static const auto reactFeatureFlagsJavaDescriptor = jni::findClassStatic(
33+
FabricMountingManager::ReactFeatureFlagsJavaDescriptor);
34+
static const auto doesUseOverflowInset =
35+
reactFeatureFlagsJavaDescriptor->getStaticMethod<jboolean()>(
36+
"doesUseOverflowInset");
37+
return doesUseOverflowInset(reactFeatureFlagsJavaDescriptor);
38+
}
39+
40+
FabricMountingManager::FabricMountingManager(
41+
std::shared_ptr<const ReactNativeConfig> &config,
42+
global_ref<jobject> &javaUIManager)
43+
: javaUIManager_(javaUIManager),
44+
enableEarlyEventEmitterUpdate_(
45+
config->getBool("react_fabric:enable_early_event_emitter_update")),
46+
disablePreallocateViews_(
47+
config->getBool("react_fabric:disabled_view_preallocation_android")),
48+
disableRevisionCheckForPreallocation_(config->getBool(
49+
"react_fabric:disable_revision_check_for_preallocation")),
50+
useOverflowInset_(doesUseOverflowInset()),
51+
shouldRememberAllocatedViews_(config->getBool(
52+
"react_native_new_architecture:remember_views_on_mount_android")),
53+
useMapBufferForViewProps_(config->getBool(
54+
"react_native_new_architecture:use_mapbuffer_for_viewprops")) {}
55+
3156
void FabricMountingManager::onSurfaceStart(SurfaceId surfaceId) {
3257
std::lock_guard lock(allocatedViewsMutex_);
3358
allocatedViewRegistry_.emplace(surfaceId, butter::set<Tag>{});
@@ -926,31 +951,5 @@ void FabricMountingManager::onAllAnimationsComplete() {
926951
allAnimationsCompleteJNI(javaUIManager_);
927952
}
928953

929-
bool doesUseOverflowInset() {
930-
static const auto reactFeatureFlagsJavaDescriptor = jni::findClassStatic(
931-
FabricMountingManager::ReactFeatureFlagsJavaDescriptor);
932-
static const auto doesUseOverflowInset =
933-
reactFeatureFlagsJavaDescriptor->getStaticMethod<jboolean()>(
934-
"doesUseOverflowInset");
935-
return doesUseOverflowInset(reactFeatureFlagsJavaDescriptor);
936-
}
937-
938-
FabricMountingManager::FabricMountingManager(
939-
std::shared_ptr<const ReactNativeConfig> &config,
940-
global_ref<jobject> &javaUIManager)
941-
: javaUIManager_(javaUIManager) {
942-
enableEarlyEventEmitterUpdate_ =
943-
config->getBool("react_fabric:enable_early_event_emitter_update");
944-
disablePreallocateViews_ =
945-
config->getBool("react_fabric:disabled_view_preallocation_android");
946-
disableRevisionCheckForPreallocation_ =
947-
config->getBool("react_fabric:disable_revision_check_for_preallocation");
948-
useOverflowInset_ = doesUseOverflowInset();
949-
shouldRememberAllocatedViews_ = config->getBool(
950-
"react_native_new_architecture:remember_views_on_mount_android");
951-
useMapBufferForViewProps_ = config->getBool(
952-
"react_native_new_architecture:use_mapbuffer_for_viewprops");
953-
}
954-
955954
} // namespace react
956955
} // namespace facebook

ReactAndroid/src/main/java/com/facebook/react/fabric/jni/FabricMountingManager.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
namespace facebook {
2424
namespace react {
2525

26-
class FabricMountingManager {
26+
class FabricMountingManager final {
2727
public:
2828
constexpr static auto UIManagerJavaDescriptor =
2929
"com/facebook/react/fabric/FabricUIManager";
@@ -61,8 +61,6 @@ class FabricMountingManager {
6161

6262
void onAllAnimationsComplete();
6363

64-
virtual ~FabricMountingManager() = default;
65-
6664
private:
6765
jni::global_ref<jobject> javaUIManager_;
6866

@@ -71,12 +69,12 @@ class FabricMountingManager {
7169
butter::map<SurfaceId, butter::set<Tag>> allocatedViewRegistry_{};
7270
std::recursive_mutex allocatedViewsMutex_;
7371

74-
bool enableEarlyEventEmitterUpdate_{false};
75-
bool disablePreallocateViews_{false};
76-
bool disableRevisionCheckForPreallocation_{false};
77-
bool useOverflowInset_{false};
78-
bool shouldRememberAllocatedViews_{false};
79-
bool useMapBufferForViewProps_{false};
72+
bool const enableEarlyEventEmitterUpdate_{false};
73+
bool const disablePreallocateViews_{false};
74+
bool const disableRevisionCheckForPreallocation_{false};
75+
bool const useOverflowInset_{false};
76+
bool const shouldRememberAllocatedViews_{false};
77+
bool const useMapBufferForViewProps_{false};
8078

8179
jni::local_ref<jobject> getProps(
8280
ShadowView const &oldShadowView,

0 commit comments

Comments
 (0)