⚡️ Speed up function _contains_jsx by 143% in PR #1565 (codeflash/optimize-pr1561-2026-02-20T03.24.55)#1569
Merged
claude[bot] merged 1 commit intocodeflash/optimize-pr1561-2026-02-20T03.24.55from Feb 20, 2026
Conversation
Using an explicit stack (iterative DFS) avoids Python recursion overhead and the temporary generator created by any(...). This reduces function-call overhead on large/deep trees and returns as soon as a matching node is found, improving both runtime and memory usage.
Contributor
PR Review SummaryPrek Checks✅ All checks passed — no formatting or linting issues found. Mypy✅ No new type errors introduced by this PR. Pre-existing mypy errors exist in Code Review✅ No critical issues found. This PR converts
Test Coverage
Notes:
Last updated: 2026-02-20 |
71988e9
into
codeflash/optimize-pr1561-2026-02-20T03.24.55
22 of 28 checks passed
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 #1565
If you approve this dependent PR, these changes will be merged into the original PR branch
codeflash/optimize-pr1561-2026-02-20T03.24.55.📄 143% (1.43x) speedup for
_contains_jsxincodeflash/languages/javascript/frameworks/react/profiler.py⏱️ Runtime :
461 microseconds→190 microseconds(best of24runs)📝 Explanation and details
Using an explicit stack (iterative DFS) avoids Python recursion overhead and the temporary generator created by any(...). This reduces function-call overhead on large/deep trees and returns as soon as a matching node is found, improving both runtime and memory usage.
✅ Correctness verification report:
🌀 Click to see Generated Regression Tests
To edit these changes
git checkout codeflash/optimize-pr1565-2026-02-20T03.34.50and push.