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
This commit is contained in:
Samuel Susla
2022-03-03 04:35:53 -08:00
committed by Facebook GitHub Bot
parent 94891ab5f8
commit f7e4037c65
2 changed files with 32 additions and 35 deletions
@@ -28,6 +28,31 @@ using namespace facebook::jni;
namespace facebook {
namespace react {
static bool doesUseOverflowInset() {
static const auto reactFeatureFlagsJavaDescriptor = jni::findClassStatic(
FabricMountingManager::ReactFeatureFlagsJavaDescriptor);
static const auto doesUseOverflowInset =
reactFeatureFlagsJavaDescriptor->getStaticMethod<jboolean()>(
"doesUseOverflowInset");
return doesUseOverflowInset(reactFeatureFlagsJavaDescriptor);
}
FabricMountingManager::FabricMountingManager(
std::shared_ptr<const ReactNativeConfig> &config,
global_ref<jobject> &javaUIManager)
: javaUIManager_(javaUIManager),
enableEarlyEventEmitterUpdate_(
config->getBool("react_fabric:enable_early_event_emitter_update")),
disablePreallocateViews_(
config->getBool("react_fabric:disabled_view_preallocation_android")),
disableRevisionCheckForPreallocation_(config->getBool(
"react_fabric:disable_revision_check_for_preallocation")),
useOverflowInset_(doesUseOverflowInset()),
shouldRememberAllocatedViews_(config->getBool(
"react_native_new_architecture:remember_views_on_mount_android")),
useMapBufferForViewProps_(config->getBool(
"react_native_new_architecture:use_mapbuffer_for_viewprops")) {}
void FabricMountingManager::onSurfaceStart(SurfaceId surfaceId) {
std::lock_guard lock(allocatedViewsMutex_);
allocatedViewRegistry_.emplace(surfaceId, butter::set<Tag>{});
@@ -926,31 +951,5 @@ void FabricMountingManager::onAllAnimationsComplete() {
allAnimationsCompleteJNI(javaUIManager_);
}
bool doesUseOverflowInset() {
static const auto reactFeatureFlagsJavaDescriptor = jni::findClassStatic(
FabricMountingManager::ReactFeatureFlagsJavaDescriptor);
static const auto doesUseOverflowInset =
reactFeatureFlagsJavaDescriptor->getStaticMethod<jboolean()>(
"doesUseOverflowInset");
return doesUseOverflowInset(reactFeatureFlagsJavaDescriptor);
}
FabricMountingManager::FabricMountingManager(
std::shared_ptr<const ReactNativeConfig> &config,
global_ref<jobject> &javaUIManager)
: javaUIManager_(javaUIManager) {
enableEarlyEventEmitterUpdate_ =
config->getBool("react_fabric:enable_early_event_emitter_update");
disablePreallocateViews_ =
config->getBool("react_fabric:disabled_view_preallocation_android");
disableRevisionCheckForPreallocation_ =
config->getBool("react_fabric:disable_revision_check_for_preallocation");
useOverflowInset_ = doesUseOverflowInset();
shouldRememberAllocatedViews_ = config->getBool(
"react_native_new_architecture:remember_views_on_mount_android");
useMapBufferForViewProps_ = config->getBool(
"react_native_new_architecture:use_mapbuffer_for_viewprops");
}
} // namespace react
} // namespace facebook
@@ -23,7 +23,7 @@
namespace facebook {
namespace react {
class FabricMountingManager {
class FabricMountingManager final {
public:
constexpr static auto UIManagerJavaDescriptor =
"com/facebook/react/fabric/FabricUIManager";
@@ -61,8 +61,6 @@ class FabricMountingManager {
void onAllAnimationsComplete();
virtual ~FabricMountingManager() = default;
private:
jni::global_ref<jobject> javaUIManager_;
@@ -71,12 +69,12 @@ class FabricMountingManager {
butter::map<SurfaceId, butter::set<Tag>> allocatedViewRegistry_{};
std::recursive_mutex allocatedViewsMutex_;
bool enableEarlyEventEmitterUpdate_{false};
bool disablePreallocateViews_{false};
bool disableRevisionCheckForPreallocation_{false};
bool useOverflowInset_{false};
bool shouldRememberAllocatedViews_{false};
bool useMapBufferForViewProps_{false};
bool const enableEarlyEventEmitterUpdate_{false};
bool const disablePreallocateViews_{false};
bool const disableRevisionCheckForPreallocation_{false};
bool const useOverflowInset_{false};
bool const shouldRememberAllocatedViews_{false};
bool const useMapBufferForViewProps_{false};
jni::local_ref<jobject> getProps(
ShadowView const &oldShadowView,