Skip to content

Commit

Permalink
Remove redundant yield break
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhentar committed Nov 21, 2016
1 parent 3783da1 commit 1a35677
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ICSharpCode.Decompiler/ILAst/GotoRemoval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ public static void RemoveRedundantCode(ILBlock method)
if (method.Body.Count > 0 && method.Body.Last().Match(ILCode.Ret) && ((ILExpression)method.Body.Last()).Arguments.Count == 0) {
method.Body.RemoveAt(method.Body.Count - 1);
}


if (method.Body.Count > 0 && method.Body.Last().Match(ILCode.YieldBreak) && ((ILExpression)method.Body.Last()).Arguments.Count == 0)
{
method.Body.RemoveAt(method.Body.Count - 1);
}

// Remove unreachable return statements
bool modified = false;
foreach(ILBlock block in method.GetSelfAndChildrenRecursive<ILBlock>()) {
Expand Down

0 comments on commit 1a35677

Please sign in to comment.