From f8b27066a182837a1bdc17298d85a61c48e4a9bb Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 29 Oct 2017 02:32:58 +0200 Subject: [PATCH] Remove ILInstructionExtensions.cs --- .../ICSharpCode.Decompiler.csproj | 1 - .../IL/ControlFlow/ConditionDetection.cs | 2 +- .../Instructions/ILInstructionExtensions.cs | 20 ------------------- 3 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 ICSharpCode.Decompiler/IL/Instructions/ILInstructionExtensions.cs diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj index 1e02da7aa..d94c974fc 100644 --- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj +++ b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj @@ -275,7 +275,6 @@ - diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs b/ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs index 97f763426..657a5f7a0 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs @@ -174,7 +174,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow // -> if (...) { ... } else { ... } goto exitPoint; // the else block is not empty or nop-only: - if (!targetBlock.IsNopBlock(ignoreExitPoint: falseExitInst)) { + if (targetBlock.Children.Any(inst => !(inst is Nop) && inst != falseExitInst)) { context.Step("Inline block as else-branch", ifInst); targetBlock.Instructions.RemoveAt(targetBlock.Instructions.Count - 1); targetBlock.Remove(); diff --git a/ICSharpCode.Decompiler/IL/Instructions/ILInstructionExtensions.cs b/ICSharpCode.Decompiler/IL/Instructions/ILInstructionExtensions.cs deleted file mode 100644 index c363dd1de..000000000 --- a/ICSharpCode.Decompiler/IL/Instructions/ILInstructionExtensions.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using System.Text; - -namespace ICSharpCode.Decompiler.IL -{ - public static class ILInstructionExtensions - { - /// - /// Determines whether a block only consists of nop instructions or is empty. - /// - public static bool IsNopBlock(this Block block, ILInstruction ignoreExitPoint = null) - { - if (block == null) - throw new ArgumentNullException(nameof(block)); - return block.Children.Count(i => !(i is Nop) && i != ignoreExitPoint) == 0; - } - } -}