Skip to content

perf: convert remaining node.children array accesses to childCount/child(i) - #562

Merged
askpt merged 1 commit into
mainfrom
repo-assist/perf-remaining-children-array-20260822-2800eb077051cd8c
Aug 22, 2026
Merged

perf: convert remaining node.children array accesses to childCount/child(i)#562
askpt merged 1 commit into
mainfrom
repo-assist/perf-remaining-children-array-20260822-2800eb077051cd8c

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This is an automated PR from Repo Assist.

AI Disclosure

This change was generated autonomously by Repo Assist based on a codebase scan for remaining performance opportunities.

Rationale

A previous perf pass (merged) converted node.children array-getter accesses to the childCount/child(i) pattern across the hot AST traversal loops in goAnalyzer, javaAnalyzer, jsLikeAnalyzer, pythonAnalyzer, and rustAnalyzer, since .children materializes a full array on every access. Five call sites were missed in that pass:

  • pythonAnalyzer.ts and rustAnalyzer.ts: the nested-function body traversal loop in the main visit() entry point — hit once per function/method found in every analyzed file (hot path).
  • jsLikeAnalyzer.ts: the nested-function grandchild traversal in analyzeNode — hit for every nested function/closure.
  • goAnalyzer.ts: findTypeInParameterList — lower frequency (once per method receiver lookup).
  • csharpAnalyzer.ts: node.children[node.children.length - 1] in the preprocessor-fragmented-method fallback — allocated the whole array just to read the last element; replaced with node.child(node.childCount - 1).

This PR converts all five to the already-established childCount/child(i) pattern used everywhere else in these files, avoiding the unnecessary array allocation.

Trade-offs

None — purely mechanical, semantically identical iteration order, matches the existing sibling loops in the same functions.

Test Status

  • npm run compile: clean
  • npm run lint: clean
  • npm run test:unit: 227 passing, no coverage regression (98.69% stmts / 94.47% branch, same as baseline)
  • vscode-test (full integration suite) not run — blocked by sandbox network restrictions as in all prior Repo Assist runs

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • releaseassets.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "releaseassets.githubusercontent.com"

See Network Configuration for more information.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@42c2ab5b4e4c9273534c39259b2e0df7f20f07e9

…ild(i)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@askpt askpt changed the title [repo-assist] perf: convert remaining node.children array accesses to childCount/child(i) perf: convert remaining node.children array accesses to childCount/child(i) Aug 22, 2026
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.90%. Comparing base (68e7846) to head (bc4529d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #562   +/-   ##
=======================================
  Coverage   97.90%   97.90%           
=======================================
  Files          10       10           
  Lines        3765     3766    +1     
  Branches      455      455           
=======================================
+ Hits         3686     3687    +1     
  Misses         79       79           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@askpt
askpt marked this pull request as ready for review August 22, 2026 14:39
@askpt
askpt self-requested a review as a code owner August 22, 2026 14:39
Copilot AI balanced review requested due to automatic review settings August 22, 2026 14:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The five mechanical conversions preserve traversal semantics and follow existing analyzer patterns.

Pull request overview

Optimizes Tree-sitter AST traversal by avoiding unnecessary children array materialization.

Changes:

  • Replaces array iteration with childCount/child(i).
  • Uses indexed access to retrieve the final C# child node.
File summaries
File Description
rustAnalyzer.ts Optimizes nested-function traversal.
pythonAnalyzer.ts Optimizes function-body traversal.
jsLikeAnalyzer.ts Optimizes nested-function child analysis.
goAnalyzer.ts Optimizes receiver parameter lookup.
csharpAnalyzer.ts Avoids allocating an array for final-child access.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@askpt
askpt merged commit c036b79 into main Aug 22, 2026
25 checks passed
@askpt
askpt deleted the repo-assist/perf-remaining-children-array-20260822-2800eb077051cd8c branch August 22, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants