perf: move instead of clone in infer_generic_call_type_args (#1202)#1387
Merged
Merged
Conversation
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.
athena-omt
approved these changes
Jul 8, 2026
athena-omt
left a comment
Contributor
There was a problem hiding this comment.
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.
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.
Slice
Implements one review-gated, behavior-preserving finding from axiomlang#1202:
"
infer_generic_call_type_argsclones the full program then overwritesfunctions+stmts".Change
infer_generic_call_type_argsrebuiltsyntax::Programby cloning all 12 metadata fields (path/imports/macros/macro_expansions/axioms/semantic_capabilities/evidence/consts/type_aliases/structs/enums/traits) and only recomputingfunctions/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 })monomorphize_programnow passesprogram.clone()once (net 12 clones → 1).Why safe
infer_generic_call_type_argshas exactly one caller (verified) and is a privatefn, so the signature change ripples nowhere else.monomorphize_programalready used the..programidiom 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 intomain), and the stale #1254/#1386 docs work.Refs axiomlang#1202.