Repository navigation
Compare prop name pointers before their characters in RawPropsParser - #59657
Merged
Merged
Conversation
On the in-order path of `RawPropsParser::at`, every lookup compared the requested prop name with the expected key using `std::string_view` equality, which runs `memcmp`. Props constructors pass the same string literal for a prop on every parse, and that literal is what the parser stored when it was prepared, so the two views usually point to the same characters. Check the pointers first and fall back to comparing the characters when they differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
javache
approved these changes
Oct 30, 2026
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D128573190. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
RawPropsParser::atfinds a prop's value by walking the parser's keys in the order the Props constructor reads them. On that path every lookup compares the requested name with the expected key usingstd::string_viewequality, which runsmemcmpover the name.Props constructors pass the same string literal for a prop on every parse (
convertRawProp(context, rawProps, "opacity", ...)), and that literal is what the parser stored inkeys_when it was prepared. So the two views almost always point to the same characters. This change compares the pointers first and only compares the characters when they differ, so the result is the same as==in every case: same pointer → equal exactly when the lengths match; different pointers → the full comparison as before.All keys in core come from string literals with static storage (
convertRawPropand the directrawProps.at("...")calls); the prefix/suffix overload ofRawProps::at, which builds a temporary string, has no callers in ReactCommon.Changelog:
[GENERAL] [CHANGED] - Props parsing compares prop name pointers before their characters
Test Plan:
yarn fantom(full suite, tester rebuilt with this change): 3314 tests pass. The other failures are unrelated to props: snapshot printing in my checkout's Jest setup, and a flaky tester crash inTesterAppDelegate::loadScriptAndRunTeststhat also happens without this change (the one suite it hit passes on rerun).clang-format --dry-run --Werrorpasses.memcmpinRawPropsParser::atRawPropsParser::atclonePropsand below)🤖 Generated with Claude Code