Fabric: Using traitCast in layoutMetricsFromShadowNode

Summary:
We use this function in Diffing, and Diffing is one of the hottest pieces of Fabric. Removing `dynamic_cast` here should improve perf. See the previous diff for more details.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20052023

fbshipit-source-id: d6427ebf076d7f8244f0aeaf16407efa2368957e
This commit is contained in:
Valentin Shergin
2020-02-26 22:08:17 -08:00
committed by Facebook Github Bot
parent b9e5ebd640
commit 3400135487
+5 -5
View File
@@ -12,11 +12,11 @@
namespace facebook {
namespace react {
static LayoutMetrics layoutMetricsFromShadowNode(const ShadowNode &shadowNode) {
auto layoutableShadowNode =
dynamic_cast<const LayoutableShadowNode *>(&shadowNode);
return layoutableShadowNode ? layoutableShadowNode->getLayoutMetrics()
: EmptyLayoutMetrics;
static LayoutMetrics layoutMetricsFromShadowNode(ShadowNode const &shadowNode) {
auto layotableShadowNode =
traitCast<LayoutableShadowNode const *>(&shadowNode);
return layotableShadowNode ? layotableShadowNode->getLayoutMetrics()
: EmptyLayoutMetrics;
}
ShadowView::ShadowView(const ShadowNode &shadowNode)