Browse Source

Add support for value types (DefaultValue) to RemoveDeadVariableInit

pull/734/merge
Siegfried Pammer 8 years ago
parent
commit
058866ff15
  1. 2
      ICSharpCode.Decompiler/IL/Transforms/RemoveDeadVariableInit.cs

2
ICSharpCode.Decompiler/IL/Transforms/RemoveDeadVariableInit.cs

@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (function.IsIterator) {
foreach (var v in function.Variables) {
if (v.Kind != VariableKind.Parameter && v.StoreCount == 1 && v.LoadCount == 0 && v.AddressCount == 0) {
if (v.StoreInstructions[0] is StLoc stloc && stloc.Value.MatchLdNull() && stloc.Parent is Block block) {
if (v.StoreInstructions[0] is StLoc stloc && (stloc.Value.MatchLdNull() || stloc.Value is DefaultValue) && stloc.Parent is Block block) {
block.Instructions.Remove(stloc);
}
}

Loading…
Cancel
Save