Skip to content

[Fabric] Optimize RawPropsParser::at out-of-order lookup using nameToIndex_ (#59759) - #59848

Open
Bahadir10 wants to merge 1 commit into
react:mainfrom
Bahadir10:fix/raw-props-out-of-order-lookup
Open

Bahadir10 wants to merge 1 commit into
react:mainfrom
Bahadir10:fix/raw-props-out-of-order-lookup

Conversation

@Bahadir10

Copy link
Copy Markdown

Summary

Fixes #59759

In RawPropsParser::at, when a prop is read out of registration order (such as a component prop struct extending ViewProps and re-reading common keys like width or backgroundColor), the parser stepped linearly through every registered key one at a time, performing equality comparisons on strings until it reached the target key. On components with many props, this incurred dozens of redundant string comparisons per parse.

Because RawPropsParser already maintains nameToIndex_ (RawPropsKeyMap), when the key does not match the cursor's next position, we can look up the key directly via nameToIndex_.at(key). This replaces the linear string comparison loop with an immediate key map lookup.

Changelog

[General][Changed] - Optimize out-of-order prop lookup in RawPropsParser::at via nameToIndex_

Test Plan

  • Added handleOutOfOrderPropsLookup in RawPropsTest.cpp validating that looking up props out of registration order returns the expected values correctly.

Summary:
**Problem**: In `RawPropsParser::at`, when a prop is read out of registration order (such as a component prop struct extending `ViewProps` and re-reading common keys like `width` or `backgroundColor`), the parser stepped linearly through every registered key one at a time, performing equality comparisons on strings until it reached the target key. On components with many props, this incurred dozens of redundant string comparisons per parse.

**Proposed change**: Since `RawPropsParser` already maintains `nameToIndex_` (`RawPropsKeyMap`), when the key does not match the cursor's next position, look up the key directly via `nameToIndex_.at(key)`. This replaces the linear string comparison loop with an immediate key map lookup.

Fixes react#59759

Changelog:
[General][Changed] - Optimize out-of-order prop lookup in `RawPropsParser::at` via `nameToIndex_`
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 7, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RawPropsParser::at steps past every registered key to find a prop read out of order, though nameToIndex_ already maps it

1 participant