⚡️ Speed up function _wrap_return_with_profiler by 30% in PR #1561 (add/support_react)#1585
Merged
claude[bot] merged 2 commits intoadd/support_reactfrom Feb 20, 2026
Conversation
I combined the two child-iteration passes in _wrap_return_with_profiler into a single loop (while still preserving the original parenthesis-handling semantics), and replaced the generator-based any(...) in _contains_jsx with an explicit loop to avoid generator overhead. I also delay decoding bytes until after determining the final slice to avoid redundant encodings/decodings. These changes reduce CPU work and memory churn while preserving exact behavior.
Contributor
PR Review SummaryPrek Checks✅ Fixed — 2 issues resolved and pushed:
All checks now pass. Mypy✅ No type errors found in changed file. Code Review✅ No critical issues found. This is a clean optimization that combines two child-iteration passes in Minor note (non-blocking): Test Coverage
Last updated: 2026-02-20 |
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.
⚡️ This pull request contains optimizations for PR #1561
If you approve this dependent PR, these changes will be merged into the original PR branch
add/support_react.📄 30% (0.30x) speedup for
_wrap_return_with_profilerincodeflash/languages/javascript/frameworks/react/profiler.py⏱️ Runtime :
25.7 microseconds→19.7 microseconds(best of250runs)📝 Explanation and details
I combined the two child-iteration passes in _wrap_return_with_profiler into a single loop (while still preserving the original parenthesis-handling semantics), and replaced the generator-based any(...) in _contains_jsx with an explicit loop to avoid generator overhead. I also delay decoding bytes until after determining the final slice to avoid redundant encodings/decodings. These changes reduce CPU work and memory churn while preserving exact behavior.
✅ Correctness verification report:
🌀 Click to see Generated Regression Tests
To edit these changes
git checkout codeflash/optimize-pr1561-2026-02-20T06.29.37and push.