Skip to content

⚡️ Speed up function extract_react_context by 15% in PR #1561 (add/support_react)#1563

Open
codeflash-ai[bot] wants to merge 7 commits intoadd/support_reactfrom
codeflash/optimize-pr1561-2026-02-20T03.15.59
Open

⚡️ Speed up function extract_react_context by 15% in PR #1561 (add/support_react)#1563
codeflash-ai[bot] wants to merge 7 commits intoadd/support_reactfrom
codeflash/optimize-pr1561-2026-02-20T03.15.59

Conversation

@codeflash-ai
Copy link
Contributor

@codeflash-ai codeflash-ai bot commented Feb 20, 2026

⚡️ 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.

This PR will be automatically closed if the original PR is merged.


📄 15% (0.15x) speedup for extract_react_context in codeflash/languages/javascript/frameworks/react/context.py

⏱️ Runtime : 11.9 milliseconds 10.3 milliseconds (best of 139 runs)

📝 Explanation and details

This optimization achieves a 15% runtime improvement (11.9ms → 10.3ms) by eliminating redundant regex compilation overhead and reducing unnecessary string operations during React component analysis.

Key Performance Improvements

1. Module-Level Regex Compilation

What changed: Three frequently-used regex patterns (HOOK_PATTERN, JSX_COMPONENT_RE, CONTEXT_RE) are now compiled once at module import time instead of being recompiled on every function call.

Why it's faster: Python's re.compile() has measurable overhead. In the original code, these patterns were compiled inside functions like _extract_hook_usages() and _extract_child_components(), meaning every component analyzed triggered fresh compilation. The line profiler shows this overhead (~300-320μs) in the original version. By hoisting to module level, this cost is paid once at import rather than repeatedly per component.

Impact on workloads: The test results show this benefits all scenarios:

  • Simple cases: 4.5-21% faster (basic hooks/children detection)
  • Complex cases: 21.8% faster (1000 hooks + 1000 child components)

The improvement scales with the number of components analyzed in a session, making it particularly valuable for analyzing large React codebases where thousands of components might be processed.

2. Optimized Parenthesis Matching in _extract_hook_usages()

What changed: Replaced character-by-character iteration (for i, char in enumerate(rest_of_line)) with direct index-based jumps using str.find() to locate only opening and closing parentheses.

Why it's faster: The original approach examined every character in the hook call body (up to 48,193 iterations in the profiler). The optimized version uses find() to jump directly between parentheses, touching only ~7,165 positions (85% fewer iterations). Python's built-in str.find() is implemented in C and is significantly faster than Python-level loops.

Line profiler evidence:

  • Original: 32.4ms total time in _extract_hook_usages(), with 25.4% (8.2ms) spent in the enumerate() loop
  • Optimized: 18.8ms total time (42% faster), with the while loop now completing in ~6.8ms

3. Reduced String Slicing

What changed: Instead of creating rest_of_line substring via component_source[match.end():], the optimized version tracks position with pos variable and slices only when needed for the final dependency array extraction.

Why it's faster: String slicing in Python creates new string objects. By deferring and minimizing slicing, we reduce memory allocation and copying overhead, particularly noticeable with large component source strings.

Test Case Performance

The annotated tests demonstrate the optimization excels across different scenarios:

  • Empty/minimal components: 14-21% faster (reduces overhead when little work is needed)
  • Typical components: 7-10% faster (3-4 hooks, several children)
  • Large-scale processing: 21.8% faster (1000 hooks, demonstrating how the optimization scales)

The consistent improvements across test cases indicate this optimization benefits both hot-path repeated analysis and bulk processing scenarios typical in static analysis tools for React codebases.

Correctness verification report:

Test Status
⚙️ Existing Unit Tests 🔘 None Found
🌀 Generated Regression Tests 31 Passed
⏪ Replay Tests 🔘 None Found
🔎 Concolic Coverage Tests 🔘 None Found
📊 Tests Coverage 93.3%
🌀 Click to see Generated Regression Tests
from pathlib import Path

# imports
import pytest  # used for our unit tests
from codeflash.languages.javascript.frameworks.react.context import \
    extract_react_context
from codeflash.languages.javascript.frameworks.react.discovery import \
    ReactComponentInfo
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer

def test_basic_hooks_children_contexts_and_optimizations():
    # A realistic component source: hooks, context usage, child JSX, inline props, function in render, and expensive op.
    source = """
function MyComponent(props) {
  // Hooks with and without dependency arrays
  useState(0);
  useEffect(() => { doSomething(a, b); }, [a, b]);
  const value = useMemo(() => computeValue(x), []);
  const ctx = useContext(MyContext);

  // Function defined inside render - should trigger MISSING_USECALLBACK suggestion
  const handleClick = () => {
    console.log('clicked');
  };

  // Expensive operation in render - should trigger MISSING_USEMEMO
  const doubled = items.map(i => i * 2);

  return (
    <div>
      <Child />
      <Another prop={{ a: 1 }} onAction={() => {}} />
      <React.Fragment />
      <Suspense />
    </div>
  );
}
"""
    # Construct a real ReactComponentInfo. The component_type annotation expects a ComponentType,
    # but the dataclass does not enforce runtime types, so a simple string is acceptable here.
    component_info = ReactComponentInfo(
        function_name="MyComponent",
        component_type="function",
        uses_hooks=(),
        returns_jsx=True,
        props_type=None,  # avoid triggering type-definition extraction which requires tree-sitter parsing
        is_memoized=False,
        start_line=1,
        end_line=200,
    )

    analyzer = TreeSitterAnalyzer("javascript")  # real analyzer instance; parse not invoked in these paths
    codeflash_output = extract_react_context(component_info, source, analyzer, Path(".")); ctx = codeflash_output # 103μs -> 98.9μs (4.50% faster)

    # Hooks: expect useEffect, useState, useMemo to be detected.
    hook_names = [h.name for h in ctx.hooks_used]

    # Find specific hook objects to assert dependency array detection
    effect_hooks = [h for h in ctx.hooks_used if h.name == "useEffect"]
    effect_hook = effect_hooks[0]

    memo_hooks = [h for h in ctx.hooks_used if h.name == "useMemo"]
    memo_hook = memo_hooks[0]

    # Optimization opportunities: verify substrings for the different detectors
    descriptions = [op.description for op in ctx.optimization_opportunities]

def test_empty_source_and_out_of_range_start_line():
    # Empty source should not crash; start_line/out-of-range behavior should be handled gracefully.
    source = ""  # completely empty file
    component_info = ReactComponentInfo(
        function_name="Empty",
        component_type="function",
        props_type=None,
        is_memoized=False,
        start_line=10,  # deliberately beyond the number of lines in source (0)
        end_line=20,
    )
    analyzer = TreeSitterAnalyzer("javascript")
    codeflash_output = extract_react_context(component_info, source, analyzer, Path(".")); ctx = codeflash_output # 17.0μs -> 14.0μs (21.0% faster)

    # Even with empty content, detect_optimization_opportunities still appends missing React.memo if not memoized
    descriptions = [op.description for op in ctx.optimization_opportunities]

def test_hook_with_nested_parentheses_and_empty_dependency_array():
    # This tests the heuristic in _extract_hook_usages for nested parentheses before the dependency array.
    source = """
function Comp() {
  useEffect(() => {
    // nested call with parentheses
    someFn(a(b(c)));
  }, []);
  return <div />;
}
"""
    component_info = ReactComponentInfo(
        function_name="Comp",
        component_type="function",
        props_type=None,
        is_memoized=True,  # set to True to avoid the missing memo optimization
        start_line=1,
        end_line=50,
    )
    analyzer = TreeSitterAnalyzer("javascript")
    codeflash_output = extract_react_context(component_info, source, analyzer, Path(".")); ctx = codeflash_output # 41.9μs -> 38.1μs (9.83% faster)

    # Should detect the useEffect and correctly identify the empty dependency array (dependency_count == 0)
    hooks = ctx.hooks_used

def test_child_component_name_variants_and_builtin_skips():
    # Ensure that recognized child component names include dot notation and skip React built-ins
    source = """
function X() {
  return (
    <div>
      <MyComponent.SubComp />
      <AnotherComponent />
      <Fragment />
      <React.Fragment />
      <Suspense />
      <React.Suspense />
    </div>
  );
}
"""
    component_info = ReactComponentInfo(
        function_name="X",
        component_type="function",
        props_type=None,
        is_memoized=True,
        start_line=1,
        end_line=100,
    )
    analyzer = TreeSitterAnalyzer("javascript")
    codeflash_output = extract_react_context(component_info, source, analyzer, Path(".")); ctx = codeflash_output # 43.4μs -> 40.4μs (7.45% faster)

def test_large_number_of_children_and_hooks_performance_like():
    # Build a large component body with 1000 child tags and 1000 hook invocations
    n = 1000
    # Many JSX child tags (C0 ... C999)
    jsx_children = "\n".join(f"<C{i} />" for i in range(n))
    # Many hook invocations; each with a single dependency variable to check dependency counting
    hook_calls = "\n".join(f"useEffect(() => {{ doThing({i}); }}, [dep{i}]);" for i in range(n))

    source = f"""
function Big() {{
  {hook_calls}
  return (
    <div>
      {jsx_children}
    </div>
  );
}}
"""
    component_info = ReactComponentInfo(
        function_name="Big",
        component_type="function",
        props_type=None,
        is_memoized=False,
        start_line=1,
        end_line=10_000,  # large end to include all lines
    )
    analyzer = TreeSitterAnalyzer("javascript")

    codeflash_output = extract_react_context(component_info, source, analyzer, Path(".")); ctx = codeflash_output # 7.92ms -> 6.50ms (21.8% faster)

    # Each hook should have a single dependency (dep{i}) according to our constructed lines
    # Check a sample: first, middle, last
    sample_indices = [0, n // 2, n - 1]
    for i in sample_indices:
        pass
# codeflash_output is used to check that the output of the original code is the same as that of the optimized code.
from pathlib import Path
from unittest.mock import MagicMock

# imports
import pytest
from codeflash.languages.javascript.frameworks.react.context import (
    _extract_child_components, _extract_context_subscriptions,
    _extract_hook_usages, extract_react_context)
from codeflash.languages.javascript.frameworks.react.discovery import (
    ComponentType, ReactComponentInfo)
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer

def test_extract_hook_usages_no_hooks():
    """Test _extract_hook_usages with source that contains no hooks."""
    source = "const x = 5;\nconst y = 10;"
    
    hooks = _extract_hook_usages(source)

def test_extract_hook_usages_useState():
    """Test _extract_hook_usages with useState hook."""
    source = "const [count, setCount] = useState(0);"
    
    hooks = _extract_hook_usages(source)

def test_extract_hook_usages_useEffect_with_deps():
    """Test _extract_hook_usages with useEffect and dependency array."""
    source = "useEffect(() => { console.log('effect'); }, [count, user]);"
    
    hooks = _extract_hook_usages(source)

def test_extract_hook_usages_multiple_hooks():
    """Test _extract_hook_usages with multiple hooks in one source."""
    source = """
    const [count, setCount] = useState(0);
    useEffect(() => {}, [count]);
    const memoized = useMemo(() => expensiveOp(), [deps]);
    """
    
    hooks = _extract_hook_usages(source)
    hook_names = [h.name for h in hooks]

def test_extract_child_components_no_components():
    """Test _extract_child_components with no child components."""
    source = "const text = 'hello';"
    analyzer = MagicMock(spec=TreeSitterAnalyzer)
    
    children = _extract_child_components(source, analyzer, source)

def test_extract_child_components_single_component():
    """Test _extract_child_components with a single child component."""
    source = "return <Button>Click</Button>;"
    analyzer = MagicMock(spec=TreeSitterAnalyzer)
    
    children = _extract_child_components(source, analyzer, source)

def test_extract_child_components_multiple_components():
    """Test _extract_child_components with multiple different components."""
    source = """
    return (
        <Container>
            <Header title="Test" />
            <Button onClick={handleClick}>Submit</Button>
            <Footer copyright={year} />
        </Container>
    );
    """
    analyzer = MagicMock(spec=TreeSitterAnalyzer)
    
    children = _extract_child_components(source, analyzer, source)

def test_extract_child_components_skips_built_ins():
    """Test _extract_child_components ignores React built-in components."""
    source = """
    return (
        <React.Fragment>
            <Suspense fallback={<Loading />}>
                <MyComponent />
            </Suspense>
        </React.Fragment>
    );
    """
    analyzer = MagicMock(spec=TreeSitterAnalyzer)
    
    children = _extract_child_components(source, analyzer, source)

def test_extract_context_subscriptions_no_context():
    """Test _extract_context_subscriptions with no context usage."""
    source = "const x = someValue;"
    
    subscriptions = _extract_context_subscriptions(source)

def test_extract_context_subscriptions_single_context():
    """Test _extract_context_subscriptions with one useContext call."""
    source = "const theme = useContext(ThemeContext);"
    
    subscriptions = _extract_context_subscriptions(source)

def test_extract_context_subscriptions_multiple_contexts():
    """Test _extract_context_subscriptions with multiple useContext calls."""
    source = """
    const theme = useContext(ThemeContext);
    const user = useContext(UserContext);
    const config = useContext(ConfigContext);
    """
    
    subscriptions = _extract_context_subscriptions(source)

def test_extract_hook_usages_empty_dependency_array():
    """Test _extract_hook_usages with empty dependency array."""
    source = "useEffect(() => { init(); }, []);"
    
    hooks = _extract_hook_usages(source)

def test_extract_hook_usages_hook_without_deps():
    """Test _extract_hook_usages with hook that has no dependency array."""
    source = "useCallback(() => { handleClick(); })"
    
    hooks = _extract_hook_usages(source)

def test_extract_hook_usages_nested_parens():
    """Test _extract_hook_usages with hooks containing nested parentheses."""
    source = "useEffect(() => { calculate(x, y); }, [x, y]);"
    
    hooks = _extract_hook_usages(source)

def test_extract_hook_usages_custom_hook():
    """Test _extract_hook_usages with custom hook (useXxx pattern)."""
    source = "const data = useCustomHook();"
    
    hooks = _extract_hook_usages(source)

def test_extract_child_components_with_dots():
    """Test _extract_child_components with dotted component names."""
    source = "return <My.Custom.Component />;"
    analyzer = MagicMock(spec=TreeSitterAnalyzer)
    
    children = _extract_child_components(source, analyzer, source)

def test_extract_child_components_case_sensitive():
    """Test _extract_child_components is case-sensitive for component names."""
    source = "<button>native</button><Button>component</Button>"
    analyzer = MagicMock(spec=TreeSitterAnalyzer)
    
    children = _extract_child_components(source, analyzer, source)

def test_extract_context_subscriptions_with_whitespace():
    """Test _extract_context_subscriptions handles whitespace variations."""
    source = "const theme = useContext  (  ThemeContext  );"
    
    subscriptions = _extract_context_subscriptions(source)

def test_extract_context_subscriptions_multiline():
    """Test _extract_context_subscriptions with multiline useContext call."""
    source = """const user = useContext(
        UserContext
    );"""
    
    subscriptions = _extract_context_subscriptions(source)

def test_extract_hook_usages_single_dependency():
    """Test _extract_hook_usages with single dependency in array."""
    source = "useEffect(() => {}, [count]);"
    
    hooks = _extract_hook_usages(source)

def test_extract_hook_usages_many_dependencies():
    """Test _extract_hook_usages with many dependencies."""
    source = "useEffect(() => {}, [a, b, c, d, e, f, g]);"
    
    hooks = _extract_hook_usages(source)

def test_extract_hook_usages_many_hooks():
    """Test _extract_hook_usages with many hooks (100 hooks)."""
    # Build source with 100 different hook usages
    hooks_source_lines = [f"const hook{i} = use{chr(65 + (i % 26))}{i}();" for i in range(100)]
    source = "\n".join(hooks_source_lines)
    
    hooks = _extract_hook_usages(source)

def test_extract_child_components_many_components():
    """Test _extract_child_components with many child components (100 components)."""
    # Build JSX with 100 different components
    jsx_lines = [f"<Component{i} />" for i in range(100)]
    source = "<div>\n" + "\n".join(jsx_lines) + "\n</div>"
    analyzer = MagicMock(spec=TreeSitterAnalyzer)
    
    children = _extract_child_components(source, analyzer, source)
    # Verify all components are found
    for i in range(100):
        pass

def test_extract_context_subscriptions_many_contexts():
    """Test _extract_context_subscriptions with many context subscriptions (100 contexts)."""
    # Build source with 100 useContext calls
    context_lines = [f"const ctx{i} = useContext(Context{i});" for i in range(100)]
    source = "\n".join(context_lines)
    
    subscriptions = _extract_context_subscriptions(source)
    # Verify all contexts are found
    for i in range(100):
        pass

def test_extract_hook_usages_deeply_nested():
    """Test _extract_hook_usages with deeply nested hook calls (1000 nested levels)."""
    # Create deeply nested function calls with hooks
    source = "useEffect(() => { "
    for i in range(500):
        source += "if (true) { "
    source += "const x = useState(0); "
    for i in range(500):
        source += "} "
    source += "}, []);"
    
    hooks = _extract_hook_usages(source)
    hook_names = [h.name for h in hooks]

def test_extract_child_components_deeply_nested_jsx():
    """Test _extract_child_components with deeply nested JSX (500 levels deep)."""
    # Create deeply nested JSX structure
    source = "<Outer0"
    for i in range(1, 250):
        source += f"><Outer{i}"
    source += "><Inner /></"
    for i in range(249, -1, -1):
        source += f"Outer{i}>"
    
    analyzer = MagicMock(spec=TreeSitterAnalyzer)
    
    children = _extract_child_components(source, analyzer, source)

To edit these changes git checkout codeflash/optimize-pr1561-2026-02-20T03.15.59 and push.

Codeflash

This optimization achieves a **15% runtime improvement** (11.9ms → 10.3ms) by eliminating redundant regex compilation overhead and reducing unnecessary string operations during React component analysis.

## Key Performance Improvements

### 1. Module-Level Regex Compilation
**What changed:** Three frequently-used regex patterns (`HOOK_PATTERN`, `JSX_COMPONENT_RE`, `CONTEXT_RE`) are now compiled once at module import time instead of being recompiled on every function call.

**Why it's faster:** Python's `re.compile()` has measurable overhead. In the original code, these patterns were compiled inside functions like `_extract_hook_usages()` and `_extract_child_components()`, meaning every component analyzed triggered fresh compilation. The line profiler shows this overhead (~300-320μs) in the original version. By hoisting to module level, this cost is paid once at import rather than repeatedly per component.

**Impact on workloads:** The test results show this benefits all scenarios:
- Simple cases: 4.5-21% faster (basic hooks/children detection)
- Complex cases: 21.8% faster (1000 hooks + 1000 child components)

The improvement scales with the number of components analyzed in a session, making it particularly valuable for analyzing large React codebases where thousands of components might be processed.

### 2. Optimized Parenthesis Matching in `_extract_hook_usages()`
**What changed:** Replaced character-by-character iteration (`for i, char in enumerate(rest_of_line)`) with direct index-based jumps using `str.find()` to locate only opening and closing parentheses.

**Why it's faster:** The original approach examined every character in the hook call body (up to 48,193 iterations in the profiler). The optimized version uses `find()` to jump directly between parentheses, touching only ~7,165 positions (85% fewer iterations). Python's built-in `str.find()` is implemented in C and is significantly faster than Python-level loops.

**Line profiler evidence:** 
- Original: 32.4ms total time in `_extract_hook_usages()`, with 25.4% (8.2ms) spent in the `enumerate()` loop
- Optimized: 18.8ms total time (42% faster), with the `while` loop now completing in ~6.8ms

### 3. Reduced String Slicing
**What changed:** Instead of creating `rest_of_line` substring via `component_source[match.end():]`, the optimized version tracks position with `pos` variable and slices only when needed for the final dependency array extraction.

**Why it's faster:** String slicing in Python creates new string objects. By deferring and minimizing slicing, we reduce memory allocation and copying overhead, particularly noticeable with large component source strings.

## Test Case Performance

The annotated tests demonstrate the optimization excels across different scenarios:

- **Empty/minimal components:** 14-21% faster (reduces overhead when little work is needed)
- **Typical components:** 7-10% faster (3-4 hooks, several children)  
- **Large-scale processing:** 21.8% faster (1000 hooks, demonstrating how the optimization scales)

The consistent improvements across test cases indicate this optimization benefits both hot-path repeated analysis and bulk processing scenarios typical in static analysis tools for React codebases.
@codeflash-ai codeflash-ai bot added the ⚡️ codeflash Optimization PR opened by Codeflash AI label Feb 20, 2026
@claude claude bot mentioned this pull request Feb 20, 2026
I replaced the per-match Match object creation (finditer + group(1)) with re.findall to get the group strings directly and removed matches in bulk via set operations. This reduces object allocations and Python-level loop overhead, giving measurable speed and memory improvements on large inputs while preserving behavior and output ordering.
@codeflash-ai
Copy link
Contributor Author

codeflash-ai bot commented Feb 20, 2026

⚡️ Codeflash found optimizations for this PR

📄 83% (0.83x) speedup for _extract_child_components in codeflash/languages/javascript/frameworks/react/context.py

⏱️ Runtime : 2.26 milliseconds 1.23 milliseconds (best of 250 runs)

A dependent PR with the suggested changes has been created. Please review:

If you approve, it will be merged into this PR (branch codeflash/optimize-pr1561-2026-02-20T03.15.59).

Static Badge

@claude
Copy link
Contributor

claude bot commented Feb 20, 2026

PR Review Summary

Prek Checks

Fixed in context.py:

  • Moved pathlib.Path import into TYPE_CHECKING block (TC003)
  • Fixed unsorted imports (I001 x2)
  • Removed blank line after function docstring (D202)
  • Committed and pushed as style: auto-fix linting issues and move Path to TYPE_CHECKING block

Remaining issues (pre-existing in base branch add/support_react, require --unsafe-fixes):

  • detector.py: TC003 (Path not in TYPE_CHECKING)
  • discovery.py: TC003, SIM110 (use any() instead of for loop)
  • profiler.py: TC003, RET504 (unnecessary assignment before return), SIM110
  • treesitter_utils.py: FURB171 x2 (membership test against single-item container)

mypy: No issues found in context.py.

Code Review

No critical issues found. The optimization is correct and behavior-preserving:

  1. Module-level regex compilation — moves re.compile() from inside function bodies to module-level constants (HOOK_PATTERN, JSX_COMPONENT_RE, CONTEXT_RE). Standard Python optimization.
  2. Optimized parenthesis matching — replaces character-by-character enumerate() loop with str.find() jumps in _extract_hook_usages(). Logic is equivalent.
  3. No API changes — function signatures unchanged, same outputs.

Test Coverage

File Status Stmts Miss Cover
languages/base.py Modified 133 2 98%
languages/javascript/frameworks/__init__.py New 0 0 100%
languages/javascript/frameworks/detector.py New 0% ⚠️
languages/javascript/frameworks/react/__init__.py New 0 0 100%
languages/javascript/frameworks/react/analyzer.py New 0% ⚠️
languages/javascript/frameworks/react/context.py New (this PR) 0% ⚠️
languages/javascript/frameworks/react/discovery.py New 131 53 60%
languages/javascript/frameworks/react/profiler.py New 0% ⚠️
languages/javascript/parse.py Modified 272 138 49%
languages/javascript/support.py Modified 1047 314 70%
languages/javascript/treesitter_utils.py New 0% ⚠️
models/function_types.py Modified 47 0 100%

Notes:

  • context.py (the file optimized by this PR) has 0% test coverage. No unit tests exist for the React framework context extraction functions. This is a pre-existing gap from the base branch (add/support_react), not introduced by this optimization PR.
  • Several new React framework files have 0% coverage — no test files for React framework functionality exist in tests/.
  • 8 pre-existing test failures in tests/test_tracer.py (unrelated to this PR).

Last updated: 2026-02-20

github-actions bot and others added 4 commits February 20, 2026 03:29
Refined the optimization to focus on the core performance improvement while maximizing code simplicity:

1. **Removed module-level `_JSX_NODE_TYPES` constant**: This micro-optimization added complexity (module-level state) without meaningful performance benefit. The original tuple is small and Python handles small tuple membership checks efficiently.

2. **Removed `reversed(children)` and associated comment**: For a boolean "contains" check, the traversal order is irrelevant. Removing this simplifies the code and eliminates the overhead of reversing children lists.

3. **Kept original variable name `node`**: Reusing `node` in the loop maintains consistency with the original code and reduces diff size.

4. **Removed unnecessary comment**: The simplified iterative approach is self-explanatory and doesn't require additional documentation.

The refined code preserves the key optimization (iterative DFS avoiding recursion and generator overhead) while being more readable and closer to the original structure. The performance benefit remains intact as the core algorithmic improvement is preserved.
…2026-02-20T03.38.42

⚡️ Speed up function `_contains_jsx` by 457% in PR #1567 (`codeflash/optimize-pr1563-2026-02-20T03.27.20`)
…2026-02-20T03.27.20

⚡️ Speed up function `_extract_child_components` by 83% in PR #1563 (`codeflash/optimize-pr1561-2026-02-20T03.15.59`)
@codeflash-ai
Copy link
Contributor Author

codeflash-ai bot commented Feb 20, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚡️ codeflash Optimization PR opened by Codeflash AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants

Comments