Convert LINQ to foreach in Helpers.VisitChildren - Reduce GC pressure

This commit is contained in:
Maarten Balliauw
2022-05-10 12:11:12 +02:00
parent b7bc640e31
commit 1cbe4b1dc8
+8 -3
View File
@@ -46,9 +46,14 @@ namespace QuestPDF.Helpers
internal static void VisitChildren(this Element? element, Action<Element?> handler)
{
foreach (var child in element.GetChildren().Where(x => x != null))
VisitChildren(child, handler);
if (element != null)
{
foreach (var child in element.GetChildren())
{
if (child != null) VisitChildren(child, handler);
}
}
handler(element);
}
}