Browse Source

Avoid ITypeDefinition.FullName. Use Name and Namespace separately to avoid string allocation. Reorder checks to improve performance on pattern mismatch.

pull/1246/head
Siegfried Pammer 7 years ago
parent
commit
08af55aa57
  1. 8
      ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs

8
ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs

@ -405,10 +405,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (!(instruction is Call call) || call.Arguments.Count != 2) if (!(instruction is Call call) || call.Arguments.Count != 2)
return false; return false;
method = call.Method; method = call.Method;
if (method.DeclaringTypeDefinition == null || method.DeclaringTypeDefinition.FullName != "System.Runtime.CompilerServices.RuntimeHelpers") if (!method.IsStatic || method.Name != "InitializeArray" || method.DeclaringTypeDefinition == null)
return false; return false;
if (method.Name != "InitializeArray") var declaringType = method.DeclaringTypeDefinition;
if (declaringType.DeclaringType != null || declaringType.Name != "RuntimeHelpers"
|| declaringType.Namespace != "System.Runtime.CompilerServices")
{
return false; return false;
}
if (!call.Arguments[0].MatchLdLoc(out array)) if (!call.Arguments[0].MatchLdLoc(out array))
return false; return false;
if (!call.Arguments[1].MatchLdMemberToken(out var member)) if (!call.Arguments[1].MatchLdMemberToken(out var member))

Loading…
Cancel
Save