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:03:14 -08:00 коммит произвёл Facebook Github Bot
Родитель b9e5ebd640
Коммит 3400135487
1 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -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)