Skip to content

Commit

Permalink
Keep fastAddProperties only in ReactNativeAttributePayloadFabric
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytrorykun committed May 7, 2024
1 parent 573c608 commit ad43eec
Showing 1 changed file with 2 additions and 68 deletions.
70 changes: 2 additions & 68 deletions packages/react-native-renderer/src/ReactNativeAttributePayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import isArray from 'shared/isArray';

import {enableEarlyReturnForPropDiffing} from 'shared/ReactFeatureFlags';
import {enableAddPropertiesFastPath} from 'shared/ReactFeatureFlags';

import type {AttributeConfiguration} from './ReactNativeTypes';

Expand Down Expand Up @@ -445,68 +444,6 @@ function diffProperties(
return updatePayload;
}

function fastAddProperties(
updatePayload: null | Object,
nextProps: Object,
validAttributes: AttributeConfiguration,
): null | Object {
let attributeConfig;
let nextProp;

for (const propKey in nextProps) {
nextProp = nextProps[propKey];

if (nextProp === undefined) {
continue;
}

attributeConfig = validAttributes[propKey];

if (attributeConfig === undefined) {
continue;
}

if (typeof nextProp === 'function') {
nextProp = (true: any);
}

if (typeof attributeConfig !== 'object') {
if (!updatePayload) {
updatePayload = ({}: {[string]: $FlowFixMe});
}
updatePayload[propKey] = nextProp;
continue;
}

if (typeof attributeConfig.process === 'function') {
if (!updatePayload) {
updatePayload = ({}: {[string]: $FlowFixMe});
}
updatePayload[propKey] = attributeConfig.process(nextProp);
continue;
}

if (isArray(nextProp)) {
for (let i = 0; i < nextProp.length; i++) {
updatePayload = fastAddProperties(
updatePayload,
nextProp[i],
((attributeConfig: any): AttributeConfiguration),
);
}
continue;
}

updatePayload = fastAddProperties(
updatePayload,
nextProp,
((attributeConfig: any): AttributeConfiguration),
);
}

return updatePayload;
}

/**
* addProperties adds all the valid props to the payload after being processed.
*/
Expand All @@ -515,11 +452,8 @@ function addProperties(
props: Object,
validAttributes: AttributeConfiguration,
): null | Object {
if (enableAddPropertiesFastPath) {
return fastAddProperties(updatePayload, props, validAttributes);
} else {
return diffProperties(updatePayload, emptyObject, props, validAttributes);
}
// TODO: Fast path
return diffProperties(updatePayload, emptyObject, props, validAttributes);
}

/**
Expand Down

0 comments on commit ad43eec

Please sign in to comment.