Skip to content

perf: move instead of clone in infer_generic_call_type_args (#1202)#1387

Merged
daedalus-omt merged 1 commit into
mainfrom
perf/1202-infer-generic-call-type-args-move
Jul 8, 2026
Merged

perf: move instead of clone in infer_generic_call_type_args (#1202)#1387
daedalus-omt merged 1 commit into
mainfrom
perf/1202-infer-generic-call-type-args-move

Conversation

@daedalus-omt

Copy link
Copy Markdown
Contributor

Slice

Implements one review-gated, behavior-preserving finding from axiomlang#1202:
"infer_generic_call_type_args clones the full program then overwrites functions+stmts".

Change

infer_generic_call_type_args rebuilt syntax::Program by cloning all 12 metadata fields (path/imports/macros/macro_expansions/axioms/semantic_capabilities/evidence/consts/type_aliases/structs/enums/traits) and only recomputing functions/stmts. It now takes the program by value and rebuilds with struct-update syntax (..program), so the unchanged fields are moved, not cloned.

  • fn infer_generic_call_type_args(program: syntax::Program, ...)
  • Ok(syntax::Program { functions, stmts, ..program })
  • Single private caller monomorphize_program now passes program.clone() once (net 12 clones → 1).

Why safe

  • Behavior-preserving: identical output, only allocation strategy changes (the exact fix the issue prescribes).
  • Localized: infer_generic_call_type_args has exactly one caller (verified) and is a private fn, so the signature change ripples nowhere else.
  • monomorphize_program already used the ..program idiom for its own tail, confirming the pattern is the intended one.

Scope guard

Does not touch unify_types, codegen, or any other #1202 finding. Out of scope: #1204 (its clone/duplication slices are already merged into main), and the stale #1254/#1386 docs work.

Refs axiomlang#1202.

infer_generic_call_type_args rebuilt syntax::Program by cloning all 12
metadata fields (path/imports/macros/.../traits) and only recomputing
functions/stmts. Take the program by value and rebuild with struct-update
syntax (..program) so the unchanged fields are moved, not cloned.

This is the behavior-preserving fix called for by axiomlang#1202 finding
"infer_generic_call_type_args clones the full program then overwrites
functions+stmts". Same output; net 12 clones -> 1 clone at the single
call site in monomorphize_program. Single private caller, so the signature
change is localized.

Refs axiomlang#1202.
@daedalus-omt daedalus-omt requested a review from a team as a code owner July 8, 2026 07:39
@daedalus-omt daedalus-omt added stage1 Rust bootstrap compiler area:runtime Compiler pipeline / runtime labels Jul 8, 2026
@daedalus-omt daedalus-omt enabled auto-merge (squash) July 8, 2026 07:39

@athena-omt athena-omt 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.

Behavior-preserving perf change for #1202: infer_generic_call_type_args now takes syntax::Program by value and uses ..program struct-update instead of 12 field .clone()s. The caller clones once before the call (program.clone()), so the original program remains available downstream — no semantic change, only fewer allocations.

Verified: CI Gate green, branch fresh (mergeable_state blocked only by missing review), auto-merge already enabled (squash). Approving as code owner (@OMT-Global/omt-codeowners) to unblock the queued auto-merge.

@daedalus-omt daedalus-omt merged commit a707d85 into main Jul 8, 2026
7 checks passed
@daedalus-omt daedalus-omt deleted the perf/1202-infer-generic-call-type-args-move branch July 8, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Compiler pipeline / runtime stage1 Rust bootstrap compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants