Repository navigation
Conversation
Props constructors read their props in the order the parser recorded them, passing the same string literals each time. `RawProps::at(const char*)` turned each name into a `std::string_view`, which runs `strlen` before the parser compares it with the expected key. The parser now takes the `const char*` directly. When it is the pointer stored for the next key and ends where that key ends, the cursor advances without measuring the name; any other name falls back to the existing `std::string_view` lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Props constructors read their props through
RawProps::at(const char*), in the order the parser recorded duringprepare, passing the same string literals every time.RawProps::atconverted each name to astd::string_viewbefore handing it toRawPropsParser::at. That conversion is astrlenof the prop name, for every prop of every node, including the many props a node does not set:BaseViewPropsalone reads well over a hundred names.In a simpleperf profile of a 40-row feed mount in RNTester (release, Galaxy A16),
__strlen_aarch64was 10.9% ofUIManager::createNodesamples, or 3.0% of all JS-thread samples during the mount.RawPropsParsernow has anat(const RawProps&, const char*)overload. If the pointer equals the storedstd::string_viewof the next expected key, and the name's terminator sits at that key's length, the cursor advances without measuring the name. The terminator check confirms the length in O(1). Any other name (out of order, repeated, or built at runtime) falls back to the existingstd::string_viewlookup, so behaviour does not change. Theprefix/suffixoverload ofRawProps::atstill builds astd::stringand keeps using thestd::string_viewpath.This builds on #59657, which compares the pointers before the characters; that comparison only happens after the name has been measured.
Changelog:
[GENERAL] [CHANGED] - Skip measuring prop names that
RawPropsParserreads in the expected orderTest Plan
New
RawPropsTest.handleRawPropsNamesFromOtherStorage: names with the same characters at other addresses, in order and out of order, and a longer name that starts with a prepared one (intValueX), which must not match.All ReactCommon C++ tests pass on macOS via the Fantom tester (
./gradlew :private:react-native-fantom:testReactCommon): 1631 passed, including the new test.node scripts/clang-format.js --checkon the changed files.RNTester release on real phones (Galaxy A16 and Pixel 9a), interleaved A/B of 5dc1d78 with and without this change, same toolchain: 12 blocks in random order × 20 rounds, each round mounting a 10-row and a 40-row feed of Views and Texts (n = 240 pairs per cell, every block at thermal status 0). JS-thread CPU from the start of the render until React's layout effect (render,
createNode, commit and layout), median, ratio after/before with bootstrap 95% CI:On the A16 this matches the
strlenshare in the profile. On the Pixel 9a the difference is within noise. Time from the trigger to the frame that shows the content did not change on either device; the change only touches the JS thread.🤖 Generated with Claude Code