Skip to content

Commit ea5d348

Browse files
authored
perf: Use static_cast for shadow node (#1180)
* perf: Use `static_cast` for shadow node * static-cast concrete state
1 parent 3116736 commit ea5d348

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

packages/nitrogen/src/views/CppHybridViewComponent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ namespace ${namespace} {
272272
void ${descriptorClassName}::adopt(react::ShadowNode& shadowNode) const {
273273
// This is called immediately after \`ShadowNode\` is created, cloned or in progress.
274274
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
275-
auto& concreteShadowNode = dynamic_cast<${shadowNodeClassName}&>(shadowNode);
275+
auto& concreteShadowNode = static_cast<${shadowNodeClassName}&>(shadowNode);
276276
const ${propsClassName}& props = concreteShadowNode.getConcreteProps();
277277
${stateClassName} state;
278278
state.setProps(props);

packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void J${stateUpdaterName}::updateViewProps(jni::alias_ref<jni::JClass> /* class
213213
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
214214
215215
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
216-
auto concreteState = std::dynamic_pointer_cast<const ConcreteStateData>(state);
216+
auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
217217
const ${stateClassName}& data = concreteState->getData();
218218
const std::optional<${propsClassName}>& maybeProps = data.getProps();
219219
if (!maybeProps.has_value()) {

packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridRecyclableTestViewStateUpdater.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void JHybridRecyclableTestViewStateUpdater::updateViewProps(jni::alias_ref<jni::
2828
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
2929

3030
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
31-
auto concreteState = std::dynamic_pointer_cast<const ConcreteStateData>(state);
31+
auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
3232
const HybridRecyclableTestViewState& data = concreteState->getData();
3333
const std::optional<HybridRecyclableTestViewProps>& maybeProps = data.getProps();
3434
if (!maybeProps.has_value()) {

packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void JHybridTestViewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /*
2828
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
2929

3030
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
31-
auto concreteState = std::dynamic_pointer_cast<const ConcreteStateData>(state);
31+
auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
3232
const HybridTestViewState& data = concreteState->getData();
3333
const std::optional<HybridTestViewProps>& maybeProps = data.getProps();
3434
if (!maybeProps.has_value()) {

packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridRecyclableTestViewComponent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ namespace margelo::nitro::test::views {
7777
void HybridRecyclableTestViewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
7878
// This is called immediately after `ShadowNode` is created, cloned or in progress.
7979
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
80-
auto& concreteShadowNode = dynamic_cast<HybridRecyclableTestViewShadowNode&>(shadowNode);
80+
auto& concreteShadowNode = static_cast<HybridRecyclableTestViewShadowNode&>(shadowNode);
8181
const HybridRecyclableTestViewProps& props = concreteShadowNode.getConcreteProps();
8282
HybridRecyclableTestViewState state;
8383
state.setProps(props);

packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridTestViewComponent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace margelo::nitro::test::views {
113113
void HybridTestViewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
114114
// This is called immediately after `ShadowNode` is created, cloned or in progress.
115115
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
116-
auto& concreteShadowNode = dynamic_cast<HybridTestViewShadowNode&>(shadowNode);
116+
auto& concreteShadowNode = static_cast<HybridTestViewShadowNode&>(shadowNode);
117117
const HybridTestViewProps& props = concreteShadowNode.getConcreteProps();
118118
HybridTestViewState state;
119119
state.setProps(props);

0 commit comments

Comments
 (0)