Skip to content

Commit e968eec

Browse files
borisbatclaude
andcommitted
linq_fold: PR F3 R1 — drop redundant clone_type(elemType) (Copilot #1)
Copilot flagged emit_decs_early_exit's `retType = clone_type(elemType)` as a double-clone since `elemType` is already `clone_type(chainInfo.finalType)`. Same pattern appeared in 3 emit_decs_walk_lane arms (last / single / single_or_default). Both `elemType` and `retType` get qmacro-spliced (apply_template clones its inputs internally), so the explicit clone is wasted work. Sharing the elemType pointer between the var-decl splice and the invoke retType splice is safe — each splice clones independently at emit time. AST byte-identical to pre-fix dump on the same 6-chain baseline. tests/linq green (1689/1689). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 411fac6 commit e968eec

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

daslib/linq_fold.das

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5423,7 +5423,7 @@ def private emit_decs_early_exit(bridge : DecsBridgeShape?;
54235423
var dispatch : DecsDispatch = DecsDispatch(Find = null)
54245424
var retType : TypeDeclPtr
54255425
if (opName == "first" || opName == "first_or_default") {
5426-
retType = clone_type(elemType)
5426+
retType = elemType
54275427
preludeStmts |> push_from <| qmacro_block_to_array() {
54285428
var $i(foundName) = false
54295429
var $i(resultName) : $t(elemType)
@@ -5680,7 +5680,7 @@ def private emit_decs_walk_lane(bridge : DecsBridgeShape?;
56805680
var retType : TypeDeclPtr
56815681
var earlyExitFind = false
56825682
if (opName == "last" || opName == "last_or_default") {
5683-
retType = clone_type(elemType)
5683+
retType = elemType
56845684
let foundName = qn("decs_found", at)
56855685
let bindName = qn("decs_lst", at)
56865686
preludeStmts |> push_from <| qmacro_block_to_array() {
@@ -5708,7 +5708,7 @@ def private emit_decs_walk_lane(bridge : DecsBridgeShape?;
57085708
}
57095709
}
57105710
} elif (opName == "single") {
5711-
retType = clone_type(elemType)
5711+
retType = elemType
57125712
let foundName = qn("decs_found", at)
57135713
let bindName = qn("decs_sng", at)
57145714
preludeStmts |> push_from <| qmacro_block_to_array() {
@@ -5726,7 +5726,7 @@ def private emit_decs_walk_lane(bridge : DecsBridgeShape?;
57265726
return <- $i(bindName)
57275727
}
57285728
} elif (opName == "single_or_default") {
5729-
retType = clone_type(elemType)
5729+
retType = elemType
57305730
let foundName = qn("decs_found", at)
57315731
let stopName = qn("decs_stop", at)
57325732
let bindName = qn("decs_sng", at)

0 commit comments

Comments
 (0)