Repository: facebook/react
File: packages/react-native-renderer/src/ReactNativeAttributePayloadFabric.js (JavaScript)

Code before:
      payload = fastAddProperties(payload, props[i], validAttributes);
    }
    return payload;
  }

  for (const propKey in props) {
    const prop = props[propKey];

    const attributeConfig = ((validAttributes[
      propKey
    ]: any): AttributeConfiguration);

    if (attributeConfig == null) {
      continue;
    }

    let newValue;

    if (prop === undefined) {
      // Discard the prop if it was previously defined.
      if (payload && payload[propKey] !== undefined) {
        newValue = null;
      } else {
        continue;
      }
    } else if (
      typeof attributeConfig === 'object' &&
      typeof attributeConfig.process === 'function'
    ) {
      // An atomic prop with custom processing.
      newValue = attributeConfig.process(prop);
    } else if (typeof prop === 'function') {
      // A function prop. It represents an event handler. Pass it to native as 'true'.
      newValue = true;
    } else if (typeof attributeConfig !== 'object') {
      // An atomic prop. Doesn't need to be flattened.
      newValue = prop;
    } else if (typeof attributeConfig.diff === 'function') {
      // An atomic prop with custom diffing. We don't need to do diffing when adding props.
      newValue = prop;
    }

    if (newValue !== undefined) {
      if (!payload) {
        payload = ({}: {[string]: $FlowFixMe});
      }
      payload[propKey] = newValue;
      continue;
    }

    payload = fastAddProperties(payload, prop, attributeConfig);

Review comment (suggestion):
Let's avoid the multiple typeof calls since this is a hot codepath

```suggestion
    } else if (typeof attributeConfig === 'object') {
       If (typeof attributeConfig.process === 'function') {
          .newValue = attributeConfig.process(prop);
       } else {
          // We can ignore diffing when adding props
          newValue = prop;
       }
    } else {
      if (typeof prop === 'function') {
         newValue = true;
      } else {
         newValue = prop;
      }
   }
```

Code after:
    for (let i = 0; i < props.length; i++) {
      payload = fastAddProperties(payload, props[i], validAttributes);
    }
    return payload;
  }

  for (const propKey in props) {
    const prop = props[propKey];

    const attributeConfig = ((validAttributes[
      propKey
    ]: any): AttributeConfiguration);

    if (attributeConfig == null) {
      continue;
    }

    let newValue;

    if (prop === undefined) {
      // Discard the prop if it was previously defined.
      if (payload && payload[propKey] !== undefined) {
        newValue = null;
      } else {
        continue;
      }
    } else if (typeof attributeConfig === 'object') {
      if (typeof attributeConfig.process === 'function') {
        // An atomic prop with custom processing.
        newValue = attributeConfig.process(prop);
      } else if (typeof attributeConfig.diff === 'function') {
        // An atomic prop with custom diffing. We don't need to do diffing when adding props.
        newValue = prop;
      }
    } else {
      if (typeof prop === 'function') {
        // A function prop. It represents an event handler. Pass it to native as 'true'.
        newValue = true;
      } else {
        // An atomic prop. Doesn't need to be flattened.
        newValue = prop;
      }
    }

    if (newValue !== undefined) {
      if (!payload) {
        payload = ({}: {[string]: $FlowFixMe});
      }
      payload[propKey] = newValue;
      continue;
    }