From 0cb0be987812a9bc3fc4efb993eaa9823ed42738 Mon Sep 17 00:00:00 2001 From: dmytrorykun Date: Thu, 2 May 2024 16:15:07 +0000 Subject: [PATCH] Introduce a faster version of the addProperties function (#28969) ## Summary This PR introduces a faster version of the `addProperties` function. This new function is basically the `diffProperties` with `prevProps` set to `null`, propagated constants, and all the unreachable code paths collapsed. ## How did you test this change? I've tested this change with [the benchmark app](https://github.com/react-native-community/RNNewArchitectureApp/tree/new-architecture-benchmarks) and got ~4.4% improvement in the view creation time. DiffTrain build for commit https://github.com/facebook/react/commit/73bcdfbae57545aa8f88ecdf67426275610b5573. --- .../vendor/react/cjs/JSXDEVRuntime-dev.js | 5 +- .../vendor/react/cjs/JSXRuntime-dev.js | 5 +- .../RKJSModules/vendor/react/cjs/React-dev.js | 7 +- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 67 +++++++++++++++++-- .../implementations/ReactFabric-prod.fb.js | 58 ++++++++++++---- .../ReactFabric-profiling.fb.js | 58 ++++++++++++---- .../ReactNativeRenderer-dev.fb.js | 67 +++++++++++++++++-- .../ReactNativeRenderer-prod.fb.js | 65 ++++++++++++------ .../ReactNativeRenderer-profiling.fb.js | 65 ++++++++++++------ 10 files changed, 317 insertions(+), 82 deletions(-) diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js index 8fcf2070f2396..3e1fd62de8fe7 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<4c8919e8adb15c1f31e630f08e73d86f>> + * @generated SignedSource<> */ 'use strict'; @@ -25,7 +25,8 @@ var dynamicFlags = dynamicFlagsUntyped; // We destructure each value before re-e var enableComponentStackLocations = dynamicFlags.enableComponentStackLocations, enableRenderableContext = dynamicFlags.enableRenderableContext, - disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses; // The rest of the flags are static for better dead code elimination. + disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses; + // The rest of the flags are static for better dead code elimination. var enableDebugTracing = false; var enableScopeAPI = false; var enableLegacyHidden = false; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js index 8068ae2d2d37c..d258e7889cee1 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<659c779c0ac134a5010cd8f6556b1b17>> + * @generated SignedSource<> */ 'use strict'; @@ -25,7 +25,8 @@ var dynamicFlags = dynamicFlagsUntyped; // We destructure each value before re-e var enableComponentStackLocations = dynamicFlags.enableComponentStackLocations, enableRenderableContext = dynamicFlags.enableRenderableContext, - disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses; // The rest of the flags are static for better dead code elimination. + disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses; + // The rest of the flags are static for better dead code elimination. var enableDebugTracing = false; var enableScopeAPI = false; var enableLegacyHidden = false; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js index 63126e36d2776..9cb578cfb30ef 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<0f88cc3fda756e3467304abd247a3db7>> + * @generated SignedSource<> */ 'use strict'; @@ -27,7 +27,7 @@ if ( } var dynamicFlagsUntyped = require('ReactNativeInternalFeatureFlags'); -var ReactVersion = '19.0.0-beta-6a68f48e'; +var ReactVersion = '19.0.0-beta-45cd200f'; // Re-export dynamic flags from the internal module. var dynamicFlags = dynamicFlagsUntyped; // We destructure each value before re-exporting to avoid a dynamic look-up on @@ -36,7 +36,8 @@ var dynamicFlags = dynamicFlagsUntyped; // We destructure each value before re-e var enableAsyncActions = dynamicFlags.enableAsyncActions, enableComponentStackLocations = dynamicFlags.enableComponentStackLocations, enableRenderableContext = dynamicFlags.enableRenderableContext, - disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses; // The rest of the flags are static for better dead code elimination. + disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses; + // The rest of the flags are static for better dead code elimination. var enableDebugTracing = false; var enableScopeAPI = false; var enableLegacyHidden = false; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index e19519a59d763..c3e908ca01c70 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -4508873393058e86bed308b56e49ec883ece59d1 +73bcdfbae57545aa8f88ecdf67426275610b5573 diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index c57c822898aaa..85e15b6401667 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<3b1926ec8be22ff21a461aebe15a8dec>> + * @generated SignedSource<<438e1cd98ae204c6c07245d77bdf2eb2>> */ 'use strict'; @@ -2003,7 +2003,8 @@ var alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, passChildrenWhenCloningPersistedNodes = dynamicFlags.passChildrenWhenCloningPersistedNodes, useModernStrictMode = dynamicFlags.useModernStrictMode, - disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses; // The rest of the flags are static for better dead code elimination. + disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses, + enableAddPropertiesFastPath = dynamicFlags.enableAddPropertiesFastPath; // The rest of the flags are static for better dead code elimination. var enableSchedulingProfiler = true; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; @@ -2352,14 +2353,70 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { return updatePayload; } + +function fastAddProperties(updatePayload, nextProps, validAttributes) { + var attributeConfig; + var nextProp; + + for (var propKey in nextProps) { + nextProp = nextProps[propKey]; + + if (nextProp === undefined) { + continue; + } + + attributeConfig = validAttributes[propKey]; + + if (attributeConfig === undefined) { + continue; + } + + if (typeof nextProp === 'function') { + nextProp = true; + } + + if (typeof attributeConfig !== 'object') { + if (!updatePayload) { + updatePayload = {}; + } + + updatePayload[propKey] = nextProp; + continue; + } + + if (typeof attributeConfig.process === 'function') { + if (!updatePayload) { + updatePayload = {}; + } + + updatePayload[propKey] = attributeConfig.process(nextProp); + continue; + } + + if (isArray(nextProp)) { + for (var i = 0; i < nextProp.length; i++) { + updatePayload = fastAddProperties(updatePayload, nextProp[i], attributeConfig); + } + + continue; + } + + updatePayload = fastAddProperties(updatePayload, nextProp, attributeConfig); + } + + return updatePayload; +} /** * addProperties adds all the valid props to the payload after being processed. */ function addProperties(updatePayload, props, validAttributes) { - // TODO: Fast path - return diffProperties(updatePayload, emptyObject$1, props, validAttributes); + if (enableAddPropertiesFastPath) { + return fastAddProperties(updatePayload, props, validAttributes); + } else { + return diffProperties(updatePayload, emptyObject$1, props, validAttributes); + } } /** * clearProperties clears all the previous props by adding a null sentinel @@ -26075,7 +26132,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-beta-197956b7'; +var ReactVersion = '19.0.0-beta-8a57d9cf'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index c3d76d4f2ee59..c74bfc264d141 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<97e06df55397eea2903e5bffade5f61e>> */ "use strict"; @@ -983,6 +983,7 @@ var alwaysThrottleRetries = dynamicFlagsUntyped.alwaysThrottleRetries, dynamicFlagsUntyped.passChildrenWhenCloningPersistedNodes, disableDefaultPropsExceptForClasses = dynamicFlagsUntyped.disableDefaultPropsExceptForClasses, + enableAddPropertiesFastPath = dynamicFlagsUntyped.enableAddPropertiesFastPath, emptyObject$1 = {}, removedKeys = null, removedKeyCount = 0, @@ -1091,12 +1092,7 @@ function diffNestedProperty( function addNestedProperty(updatePayload, nextProp, validAttributes) { if (!nextProp) return updatePayload; if (!isArrayImpl(nextProp)) - return diffProperties( - updatePayload, - emptyObject$1, - nextProp, - validAttributes - ); + return addProperties(updatePayload, nextProp, validAttributes); for (var i = 0; i < nextProp.length; i++) updatePayload = addNestedProperty( updatePayload, @@ -1206,6 +1202,44 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ))))); return updatePayload; } +function fastAddProperties(updatePayload, nextProps, validAttributes) { + var propKey; + for (propKey in nextProps) { + var nextProp = nextProps[propKey]; + if (void 0 !== nextProp) { + var attributeConfig = validAttributes[propKey]; + if (void 0 !== attributeConfig) + if ( + ("function" === typeof nextProp && (nextProp = !0), + "object" !== typeof attributeConfig) + ) + updatePayload || (updatePayload = {}), + (updatePayload[propKey] = nextProp); + else if ("function" === typeof attributeConfig.process) + updatePayload || (updatePayload = {}), + (updatePayload[propKey] = attributeConfig.process(nextProp)); + else if (isArrayImpl(nextProp)) + for (var i = 0; i < nextProp.length; i++) + updatePayload = fastAddProperties( + updatePayload, + nextProp[i], + attributeConfig + ); + else + updatePayload = fastAddProperties( + updatePayload, + nextProp, + attributeConfig + ); + } + } + return updatePayload; +} +function addProperties(updatePayload, props, validAttributes) { + return enableAddPropertiesFastPath + ? fastAddProperties(updatePayload, props, validAttributes) + : diffProperties(updatePayload, emptyObject$1, props, validAttributes); +} function batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); } @@ -1604,9 +1638,8 @@ var scheduleTimeout = setTimeout, cancelTimeout = clearTimeout; function cloneHiddenInstance(instance) { var node = instance.node; - var JSCompiler_inline_result = diffProperties( + var JSCompiler_inline_result = addProperties( null, - emptyObject$1, { style: { display: "none" } }, instance.canonical.viewConfig.validAttributes ); @@ -7351,9 +7384,8 @@ function completeWork(current, workInProgress, renderLanes) { current = nextReactTag; nextReactTag += 2; renderLanes = getViewConfigForType(renderLanes); - newChildSet = diffProperties( + newChildSet = addProperties( null, - emptyObject$1, newProps, renderLanes.validAttributes ); @@ -10613,7 +10645,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1118 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "19.0.0-beta-9a489885", + version: "19.0.0-beta-5fd3967c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10656,7 +10688,7 @@ var internals$jscomp$inline_1385 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-beta-9a489885" + reconcilerVersion: "19.0.0-beta-5fd3967c" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1386 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index b3416886fcf42..61530fb4a02b2 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<0cb20923f97d85199b33fe4f36251a51>> + * @generated SignedSource<<6a5f873752147d634c1a5052381376b9>> */ "use strict"; @@ -987,6 +987,7 @@ var alwaysThrottleRetries = dynamicFlagsUntyped.alwaysThrottleRetries, dynamicFlagsUntyped.passChildrenWhenCloningPersistedNodes, disableDefaultPropsExceptForClasses = dynamicFlagsUntyped.disableDefaultPropsExceptForClasses, + enableAddPropertiesFastPath = dynamicFlagsUntyped.enableAddPropertiesFastPath, emptyObject$1 = {}, removedKeys = null, removedKeyCount = 0, @@ -1095,12 +1096,7 @@ function diffNestedProperty( function addNestedProperty(updatePayload, nextProp, validAttributes) { if (!nextProp) return updatePayload; if (!isArrayImpl(nextProp)) - return diffProperties( - updatePayload, - emptyObject$1, - nextProp, - validAttributes - ); + return addProperties(updatePayload, nextProp, validAttributes); for (var i = 0; i < nextProp.length; i++) updatePayload = addNestedProperty( updatePayload, @@ -1210,6 +1206,44 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ))))); return updatePayload; } +function fastAddProperties(updatePayload, nextProps, validAttributes) { + var propKey; + for (propKey in nextProps) { + var nextProp = nextProps[propKey]; + if (void 0 !== nextProp) { + var attributeConfig = validAttributes[propKey]; + if (void 0 !== attributeConfig) + if ( + ("function" === typeof nextProp && (nextProp = !0), + "object" !== typeof attributeConfig) + ) + updatePayload || (updatePayload = {}), + (updatePayload[propKey] = nextProp); + else if ("function" === typeof attributeConfig.process) + updatePayload || (updatePayload = {}), + (updatePayload[propKey] = attributeConfig.process(nextProp)); + else if (isArrayImpl(nextProp)) + for (var i = 0; i < nextProp.length; i++) + updatePayload = fastAddProperties( + updatePayload, + nextProp[i], + attributeConfig + ); + else + updatePayload = fastAddProperties( + updatePayload, + nextProp, + attributeConfig + ); + } + } + return updatePayload; +} +function addProperties(updatePayload, props, validAttributes) { + return enableAddPropertiesFastPath + ? fastAddProperties(updatePayload, props, validAttributes) + : diffProperties(updatePayload, emptyObject$1, props, validAttributes); +} function batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); } @@ -1726,9 +1760,8 @@ var scheduleTimeout = setTimeout, cancelTimeout = clearTimeout; function cloneHiddenInstance(instance) { var node = instance.node; - var JSCompiler_inline_result = diffProperties( + var JSCompiler_inline_result = addProperties( null, - emptyObject$1, { style: { display: "none" } }, instance.canonical.viewConfig.validAttributes ); @@ -7617,9 +7650,8 @@ function completeWork(current, workInProgress, renderLanes) { current = nextReactTag; nextReactTag += 2; renderLanes = getViewConfigForType(renderLanes); - newChildSet = diffProperties( + newChildSet = addProperties( null, - emptyObject$1, newProps, renderLanes.validAttributes ); @@ -11318,7 +11350,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1198 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "19.0.0-beta-781ecc88", + version: "19.0.0-beta-87fa5d3f", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -11374,7 +11406,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-beta-781ecc88" + reconcilerVersion: "19.0.0-beta-87fa5d3f" }); exports.createPortal = function (children, containerTag) { return createPortal$1( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 13023703e2c96..662bf2fe61739 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ 'use strict'; @@ -2350,7 +2350,8 @@ var alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, enableRenderableContext = dynamicFlags.enableRenderableContext, enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, useModernStrictMode = dynamicFlags.useModernStrictMode, - disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses; // The rest of the flags are static for better dead code elimination. + disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses, + enableAddPropertiesFastPath = dynamicFlags.enableAddPropertiesFastPath; // The rest of the flags are static for better dead code elimination. var enableSchedulingProfiler = true; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; @@ -3382,14 +3383,70 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { return updatePayload; } + +function fastAddProperties(updatePayload, nextProps, validAttributes) { + var attributeConfig; + var nextProp; + + for (var propKey in nextProps) { + nextProp = nextProps[propKey]; + + if (nextProp === undefined) { + continue; + } + + attributeConfig = validAttributes[propKey]; + + if (attributeConfig === undefined) { + continue; + } + + if (typeof nextProp === 'function') { + nextProp = true; + } + + if (typeof attributeConfig !== 'object') { + if (!updatePayload) { + updatePayload = {}; + } + + updatePayload[propKey] = nextProp; + continue; + } + + if (typeof attributeConfig.process === 'function') { + if (!updatePayload) { + updatePayload = {}; + } + + updatePayload[propKey] = attributeConfig.process(nextProp); + continue; + } + + if (isArray(nextProp)) { + for (var i = 0; i < nextProp.length; i++) { + updatePayload = fastAddProperties(updatePayload, nextProp[i], attributeConfig); + } + + continue; + } + + updatePayload = fastAddProperties(updatePayload, nextProp, attributeConfig); + } + + return updatePayload; +} /** * addProperties adds all the valid props to the payload after being processed. */ function addProperties(updatePayload, props, validAttributes) { - // TODO: Fast path - return diffProperties(updatePayload, emptyObject$1, props, validAttributes); + if (enableAddPropertiesFastPath) { + return fastAddProperties(updatePayload, props, validAttributes); + } else { + return diffProperties(updatePayload, emptyObject$1, props, validAttributes); + } } /** * clearProperties clears all the previous props by adding a null sentinel @@ -26487,7 +26544,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-beta-0126d00e'; +var ReactVersion = '19.0.0-beta-f77489ba'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 2b10d57430365..1eea7ed39e4f5 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<29b6d6559ba3d8f7ff9f1592b99ed8f4>> + * @generated SignedSource<<2f2f979409296aff4c730c9db543982b>> */ "use strict"; @@ -1126,6 +1126,7 @@ var alwaysThrottleRetries = dynamicFlagsUntyped.alwaysThrottleRetries, enableUnifiedSyncLane = dynamicFlagsUntyped.enableUnifiedSyncLane, disableDefaultPropsExceptForClasses = dynamicFlagsUntyped.disableDefaultPropsExceptForClasses, + enableAddPropertiesFastPath = dynamicFlagsUntyped.enableAddPropertiesFastPath, REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), @@ -1492,12 +1493,7 @@ function diffNestedProperty( function addNestedProperty(updatePayload, nextProp, validAttributes) { if (!nextProp) return updatePayload; if (!isArrayImpl(nextProp)) - return diffProperties( - updatePayload, - emptyObject$1, - nextProp, - validAttributes - ); + return addProperties(updatePayload, nextProp, validAttributes); for (var i = 0; i < nextProp.length; i++) updatePayload = addNestedProperty( updatePayload, @@ -1607,6 +1603,44 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ))))); return updatePayload; } +function fastAddProperties(updatePayload, nextProps, validAttributes) { + var propKey; + for (propKey in nextProps) { + var nextProp = nextProps[propKey]; + if (void 0 !== nextProp) { + var attributeConfig = validAttributes[propKey]; + if (void 0 !== attributeConfig) + if ( + ("function" === typeof nextProp && (nextProp = !0), + "object" !== typeof attributeConfig) + ) + updatePayload || (updatePayload = {}), + (updatePayload[propKey] = nextProp); + else if ("function" === typeof attributeConfig.process) + updatePayload || (updatePayload = {}), + (updatePayload[propKey] = attributeConfig.process(nextProp)); + else if (isArrayImpl(nextProp)) + for (var i = 0; i < nextProp.length; i++) + updatePayload = fastAddProperties( + updatePayload, + nextProp[i], + attributeConfig + ); + else + updatePayload = fastAddProperties( + updatePayload, + nextProp, + attributeConfig + ); + } + } + return updatePayload; +} +function addProperties(updatePayload, props, validAttributes) { + return enableAddPropertiesFastPath + ? fastAddProperties(updatePayload, props, validAttributes) + : diffProperties(updatePayload, emptyObject$1, props, validAttributes); +} function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function () { if ( @@ -1657,9 +1691,8 @@ var ReactNativeFiberHostComponent = (function () { ); }; _proto.setNativeProps = function (nativeProps) { - nativeProps = diffProperties( + nativeProps = addProperties( null, - emptyObject$1, nativeProps, this.viewConfig.validAttributes ); @@ -7238,12 +7271,7 @@ function completeWork(current, workInProgress, renderLanes) { renderLanes = rootInstanceStackCursor.current; current = allocateTag(); type = getViewConfigForType(type); - var updatePayload = diffProperties( - null, - emptyObject$1, - newProps, - type.validAttributes - ); + var updatePayload = addProperties(null, newProps, type.validAttributes); ReactNativePrivateInterface.UIManager.createView( current, type.uiViewClassName, @@ -8455,9 +8483,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { if (((newProps = root.stateNode), viewConfig)) { var viewConfig$jscomp$0 = newProps.viewConfig; - var updatePayload$jscomp$0 = diffProperties( + var updatePayload$jscomp$0 = addProperties( null, - emptyObject$1, { style: { display: "none" } }, viewConfig$jscomp$0.validAttributes ); @@ -10834,7 +10861,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1186 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "19.0.0-beta-8879f21c", + version: "19.0.0-beta-7054616c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10877,7 +10904,7 @@ var internals$jscomp$inline_1470 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-beta-8879f21c" + reconcilerVersion: "19.0.0-beta-7054616c" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1471 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 1f6ebcb2901ab..1527c6ec6d03b 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<06820f12c0e85d0af8fe960e3776ec34>> + * @generated SignedSource<> */ "use strict"; @@ -1130,6 +1130,7 @@ var alwaysThrottleRetries = dynamicFlagsUntyped.alwaysThrottleRetries, enableUnifiedSyncLane = dynamicFlagsUntyped.enableUnifiedSyncLane, disableDefaultPropsExceptForClasses = dynamicFlagsUntyped.disableDefaultPropsExceptForClasses, + enableAddPropertiesFastPath = dynamicFlagsUntyped.enableAddPropertiesFastPath, REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), @@ -1496,12 +1497,7 @@ function diffNestedProperty( function addNestedProperty(updatePayload, nextProp, validAttributes) { if (!nextProp) return updatePayload; if (!isArrayImpl(nextProp)) - return diffProperties( - updatePayload, - emptyObject$1, - nextProp, - validAttributes - ); + return addProperties(updatePayload, nextProp, validAttributes); for (var i = 0; i < nextProp.length; i++) updatePayload = addNestedProperty( updatePayload, @@ -1611,6 +1607,44 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ))))); return updatePayload; } +function fastAddProperties(updatePayload, nextProps, validAttributes) { + var propKey; + for (propKey in nextProps) { + var nextProp = nextProps[propKey]; + if (void 0 !== nextProp) { + var attributeConfig = validAttributes[propKey]; + if (void 0 !== attributeConfig) + if ( + ("function" === typeof nextProp && (nextProp = !0), + "object" !== typeof attributeConfig) + ) + updatePayload || (updatePayload = {}), + (updatePayload[propKey] = nextProp); + else if ("function" === typeof attributeConfig.process) + updatePayload || (updatePayload = {}), + (updatePayload[propKey] = attributeConfig.process(nextProp)); + else if (isArrayImpl(nextProp)) + for (var i = 0; i < nextProp.length; i++) + updatePayload = fastAddProperties( + updatePayload, + nextProp[i], + attributeConfig + ); + else + updatePayload = fastAddProperties( + updatePayload, + nextProp, + attributeConfig + ); + } + } + return updatePayload; +} +function addProperties(updatePayload, props, validAttributes) { + return enableAddPropertiesFastPath + ? fastAddProperties(updatePayload, props, validAttributes) + : diffProperties(updatePayload, emptyObject$1, props, validAttributes); +} function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function () { if ( @@ -1661,9 +1695,8 @@ var ReactNativeFiberHostComponent = (function () { ); }; _proto.setNativeProps = function (nativeProps) { - nativeProps = diffProperties( + nativeProps = addProperties( null, - emptyObject$1, nativeProps, this.viewConfig.validAttributes ); @@ -7504,12 +7537,7 @@ function completeWork(current, workInProgress, renderLanes) { renderLanes = rootInstanceStackCursor.current; current = allocateTag(); type = getViewConfigForType(type); - var updatePayload = diffProperties( - null, - emptyObject$1, - newProps, - type.validAttributes - ); + var updatePayload = addProperties(null, newProps, type.validAttributes); ReactNativePrivateInterface.UIManager.createView( current, type.uiViewClassName, @@ -8938,9 +8966,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { if (((newProps = root.stateNode), viewConfig)) { var viewConfig$jscomp$0 = newProps.viewConfig; - var updatePayload$jscomp$0 = diffProperties( + var updatePayload$jscomp$0 = addProperties( null, - emptyObject$1, { style: { display: "none" } }, viewConfig$jscomp$0.validAttributes ); @@ -11540,7 +11567,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1266 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "19.0.0-beta-2ba13034", + version: "19.0.0-beta-650dcd3b", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -11596,7 +11623,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-beta-2ba13034" + reconcilerVersion: "19.0.0-beta-650dcd3b" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function (reactTag) {