Browse Source

Optimize performance of debug builds: only call string.Format, if assertion fails.

pull/1236/head
Siegfried Pammer 8 years ago
parent
commit
e92b9fe5e4
  1. 8
      ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs

8
ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs

@ -121,12 +121,12 @@ namespace ICSharpCode.Decompiler.IL
int firstArgument = (OpCode != OpCode.NewObj && !Method.IsStatic) ? 1 : 0; int firstArgument = (OpCode != OpCode.NewObj && !Method.IsStatic) ? 1 : 0;
Debug.Assert(Method.Parameters.Count + firstArgument == Arguments.Count); Debug.Assert(Method.Parameters.Count + firstArgument == Arguments.Count);
if (firstArgument == 1) { if (firstArgument == 1) {
Debug.Assert(Arguments[0].ResultType == ExpectedTypeForThisPointer(ConstrainedTo ?? Method.DeclaringType), if (!(Arguments[0].ResultType == ExpectedTypeForThisPointer(ConstrainedTo ?? Method.DeclaringType)))
$"Stack type mismatch in 'this' argument in call to {Method.Name}()"); Debug.Fail($"Stack type mismatch in 'this' argument in call to {Method.Name}()");
} }
for (int i = 0; i < Method.Parameters.Count; ++i) { for (int i = 0; i < Method.Parameters.Count; ++i) {
Debug.Assert(Arguments[firstArgument + i].ResultType == Method.Parameters[i].Type.GetStackType(), if (!(Arguments[firstArgument + i].ResultType == Method.Parameters[i].Type.GetStackType()))
$"Stack type mismatch in parameter {i} in call to {Method.Name}()"); Debug.Fail($"Stack type mismatch in parameter {i} in call to {Method.Name}()");
} }
} }

Loading…
Cancel
Save