diff --git a/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs b/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs index 7b4c5c82b..ec5aeb2b1 100644 --- a/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs +++ b/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs @@ -18,7 +18,19 @@ namespace Decompiler { public IEnumerable GetSelfAndChildrenRecursive() where T: ILNode { - return TreeTraversal.PreOrder(this, c => c != null ? c.GetChildren() : null).OfType(); + List result = new List(16); + AccumulateSelfAndChildrenRecursive(result); + return result; + } + + void AccumulateSelfAndChildrenRecursive(List list) where T:ILNode + { + if (this is T) + list.Add((T)this); + foreach (ILNode node in this.GetChildren()) { + if (node != null) + node.AccumulateSelfAndChildrenRecursive(list); + } } public virtual IEnumerable GetChildren()