From e92b9fe5e4e528178e2bf3b4d9193cd43610baf0 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 24 Jul 2018 20:56:21 +0200 Subject: [PATCH] Optimize performance of debug builds: only call string.Format, if assertion fails. --- ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs index 81344b8ce..0835cab35 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs @@ -121,12 +121,12 @@ namespace ICSharpCode.Decompiler.IL int firstArgument = (OpCode != OpCode.NewObj && !Method.IsStatic) ? 1 : 0; Debug.Assert(Method.Parameters.Count + firstArgument == Arguments.Count); if (firstArgument == 1) { - Debug.Assert(Arguments[0].ResultType == ExpectedTypeForThisPointer(ConstrainedTo ?? Method.DeclaringType), - $"Stack type mismatch in 'this' argument in call to {Method.Name}()"); + if (!(Arguments[0].ResultType == ExpectedTypeForThisPointer(ConstrainedTo ?? Method.DeclaringType))) + Debug.Fail($"Stack type mismatch in 'this' argument in call to {Method.Name}()"); } for (int i = 0; i < Method.Parameters.Count; ++i) { - Debug.Assert(Arguments[firstArgument + i].ResultType == Method.Parameters[i].Type.GetStackType(), - $"Stack type mismatch in parameter {i} in call to {Method.Name}()"); + if (!(Arguments[firstArgument + i].ResultType == Method.Parameters[i].Type.GetStackType())) + Debug.Fail($"Stack type mismatch in parameter {i} in call to {Method.Name}()"); } }