Skip to content

Commit 6ca3863

Browse files
Fix #1135: Redundant constant "&& true" added to decompiled code.
Suppress && / || transformation, if rhs is the identity of the operator.
1 parent 6096b7d commit 6ca3863

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,11 +2203,11 @@ protected internal override TranslatedExpression VisitIfInstruction(IfInstructio
22032203
BinaryOperatorType op = BinaryOperatorType.Any;
22042204
TranslatedExpression rhs = default(TranslatedExpression);
22052205

2206-
if (inst.MatchLogicAnd(out var lhsInst, out var rhsInst)) {
2206+
if (inst.MatchLogicAnd(out var lhsInst, out var rhsInst) && !rhsInst.MatchLdcI4(1)) {
22072207
op = BinaryOperatorType.ConditionalAnd;
22082208
Debug.Assert(rhsInst == inst.TrueInst);
22092209
rhs = trueBranch;
2210-
} else if (inst.MatchLogicOr(out lhsInst, out rhsInst)) {
2210+
} else if (inst.MatchLogicOr(out lhsInst, out rhsInst) && !rhsInst.MatchLdcI4(0)) {
22112211
op = BinaryOperatorType.ConditionalOr;
22122212
Debug.Assert(rhsInst == inst.FalseInst);
22132213
rhs = falseBranch;

0 commit comments

Comments
 (0)