Skip to content

Commit 4a54b45

Browse files
Copilotdadhi
andauthored
Simplify discard call sites: inline single-use bool vars, remove redundant comments
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/efa537b8-0c0e-4172-9ba3-1401feacbf6a Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
1 parent f973bd3 commit 4a54b45

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/FastExpressionCompiler/FastExpressionCompiler.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10938,8 +10938,7 @@ private static StringBuilder ToCSharpBlock(this Expression expr, StringBuilder s
1093810938
else
1093910939
{
1094010940
sb.NewLineIndent(lineIndent + indentSpaces);
10941-
var needsDiscard = expr != null && expr.NeedsDiscardWhenUsedAsStatement();
10942-
if (needsDiscard) // it requires some assignment target to avoid error or warning
10941+
if (expr != null && expr.NeedsDiscardWhenUsedAsStatement())
1094310942
sb.Append("_ = ");
1094410943
sb = expr?.ToCSharpString(sb, EnclosedIn.ParensByDefault, ref ctx,
1094510944
lineIndent + indentSpaces, stripNamespace, printType, indentSpaces, notRecognizedToCode) ?? sb.Append("null");
@@ -11164,7 +11163,7 @@ private static StringBuilder BlockToCSharpString(this BlockExpression b, StringB
1116411163
sb.NewLineIndent(lineIndent);
1116511164
var nodeType = expr.NodeType;
1116611165
var returningCondOrCoalesceOrCall = expr.NeedsDiscardWhenUsedAsStatement();
11167-
if (returningCondOrCoalesceOrCall) // it requires some assignment target to avoid error or warning
11166+
if (returningCondOrCoalesceOrCall)
1116811167
sb.Append("_ = ");
1116911168

1117011169
expr.ToCSharpString(sb, EnclosedIn.Block, ref ctx,

0 commit comments

Comments
 (0)