Skip to content

Look up props read out of order by name in RawPropsParser - #59760

Open
lazerg wants to merge 2 commits into
react:mainfrom
lazerg:fix/issue-59759-raw-props-parser-lookup
Open

lazerg wants to merge 2 commits into
react:mainfrom
lazerg:fix/issue-59759-raw-props-parser-lookup

Conversation

@lazerg

@lazerg lazerg commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Summary:

When a Props constructor reads a key that isn't the next one in the prepared order, RawPropsParser::at walked the cursor round keys_ one key at a time until it hit it. That happens on every parse for props that extend ViewProps and read one of View's keys again (width, backgroundColor, ...), costing up to one comparison per registered key. The parser already keeps nameToIndex_ for preparse, so now a miss on the next key looks the key up there and moves the cursor to its index. In-order reads are unchanged.

A key that was never seen while preparing now returns nullptr in release builds too, instead of looping forever.

Fixes #59759

Changelog:

[GENERAL] [CHANGED] - Props parsing looks up props read out of order by name instead of scanning every key

Test Plan:

Built RawPropsTest.cpp (minus the Hermes test) against this change with Homebrew folly/gtest on macOS: all tests pass in debug. In a release build, reading an unknown key returns nullptr with this change and hangs on main.

A small benchmark with a 100-key Props struct that re-reads two keys after the in-order pass, 200k parses in release: 222 ms on main, 191 ms with this change.

scripts/clang-format is clean. Not run on a device.

@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 2, 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 2, 2026
@meta-codesync

meta-codesync Bot commented Nov 3, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D129355825.

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

2 participants