Skip to content

[Repo Assist] [All] Fix unnecessary allocations in AST visitor for Import expressions#4455

Merged
dbrattli merged 2 commits intomainfrom
repo-assist/perf-import-visit-alloc-2026-03-28-17577a77826b0896
Apr 3, 2026
Merged

[Repo Assist] [All] Fix unnecessary allocations in AST visitor for Import expressions#4455
dbrattli merged 2 commits intomainfrom
repo-assist/perf-import-visit-alloc-2026-03-28-17577a77826b0896

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

  • Fix the visit function in Transforms.Util.fs unnecessarily reconstructing Import expressions on every AST traversal pass
  • Eliminates redundant object allocations for every Import node in every transformation pass

Root Cause

The visit function (used by visitFromInsideOut and visitFromOutsideIn) had this code for Import:

| Import(info, t, r) ->
    Import(
        { info with
            Selector = info.Selector
            Path = info.Path
        },
        t,
        r
    )

This creates a new ImportInfo record (copying all fields back to themselves) and a new Import DU case on every traversal, even though Import has no sub-expressions to visit. The getSubExpressions function confirms this — it returns [] for Import.

Fix

Return e directly, consistent with IdentExpr and other leaf expressions:

| Import _ -> e // Import has no sub-expressions to visit

Impact

Every Import expression in the Fable AST is visited 9 times during the transformation pipeline (getTransformations returns 9 passes). A typical file may contain dozens to hundreds of import expressions. For each one, this fix saves:

  • 1 ImportInfo record allocation
  • 1 Import DU case allocation

No functional change — the outputs are identical. All targets are affected since visit/visitFromInsideOut/visitFromOutsideIn are shared across all code generators.

🤖 Generated with Repo Assist

Note

🔒 Integrity filtering filtered 58 items

Integrity filtering activated and filtered the following items during workflow execution.
This happens when a tool call accesses a resource that does not meet the required integrity or secrecy level of the workflow.

  • #4454 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4393 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4220 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4166 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4143 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4104 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4044 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4038 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #3290 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #2279 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #2154 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:[Feature] Array2D operations #1764 (list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:DateTime.ParseExact breaks REPL #2003 (list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:Is there a way to get attributes on a union case? #2026 (list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:Reflection for classes #2027 (list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:StackOverflowException when compiling large match expression #2039 (list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • ... and 42 more items

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

The visit function in Transforms.Util.fs was reconstructing Import
expressions by copying all record fields back to themselves, allocating
a new ImportInfo record and Import DU case on every traversal pass even
though Import has no sub-expressions to visit (confirmed by getSubExpressions
returning [] for Import).

Fix: return the original expression directly, consistent with IdentExpr
and other leaf expressions that also have no sub-expressions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added automation Automated changes repo-assist Created by Repo Assist labels Mar 28, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dbrattli dbrattli marked this pull request as ready for review April 3, 2026 08:10
@dbrattli dbrattli merged commit 2179a40 into main Apr 3, 2026
23 checks passed
@dbrattli dbrattli deleted the repo-assist/perf-import-visit-alloc-2026-03-28-17577a77826b0896 branch April 3, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automated changes repo-assist Created by Repo Assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant