Skip to content

Commit

Permalink
avoid the multiple typeof calls since this is a hot codepath
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Jan 30, 2025
1 parent 25b1b72 commit 12b2e7d
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -494,21 +494,22 @@ function fastAddProperties(
} 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;
} 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) {
Expand Down

0 comments on commit 12b2e7d

Please sign in to comment.