From e02ca334b17a8abbdc51bc38fa0e517a9e7d1969 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Tue, 16 Jul 2024 04:38:45 -0700 Subject: [PATCH] Skip getProperty calls for unreferenced props in RawPropsParser (#45456) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45456 Small perf improvement when using enableCppPropsIteratorSetter Changelog: [Internal] Reviewed By: sammy-SC, mdvacca Differential Revision: D59699469 fbshipit-source-id: d65a5e26faf218d0b79c9ac691007310b6db4182 --- .../ReactCommon/react/renderer/core/RawPropsParser.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.cpp b/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.cpp index 435d21ff87f..122956d33c7 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.cpp @@ -125,10 +125,7 @@ void RawPropsParser::preparse(const RawProps& rawProps) const noexcept { for (size_t i = 0; i < count; i++) { auto nameValue = names.getValueAtIndex(runtime, i).getString(runtime); - auto value = object.getProperty(runtime, nameValue); - auto name = nameValue.utf8(runtime); - auto keyIndex = nameToIndex_.at( name.data(), static_cast(name.size())); @@ -137,6 +134,8 @@ void RawPropsParser::preparse(const RawProps& rawProps) const noexcept { } rawProps.keyIndexToValueIndex_[keyIndex] = valueIndex; + + auto value = object.getProperty(runtime, nameValue); rawProps.values_.push_back( RawValue(jsi::dynamicFromValue(runtime, value))); valueIndex++;