From 458b3792087c42b5b785c58401eb7120e169ede5 Mon Sep 17 00:00:00 2001 From: MarcinZiabek Date: Tue, 7 Mar 2023 21:22:45 +0100 Subject: [PATCH] Remove loop to calculate maximum (target) width, remove capturing lambda --- Source/QuestPDF/Elements/Column.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/QuestPDF/Elements/Column.cs b/Source/QuestPDF/Elements/Column.cs index 1c9e50d..3d065b8 100644 --- a/Source/QuestPDF/Elements/Column.cs +++ b/Source/QuestPDF/Elements/Column.cs @@ -87,6 +87,7 @@ namespace QuestPDF.Elements private ICollection PlanLayout(Size availableSpace) { var topOffset = 0f; + var targetWidth = 0f; var commands = new List(); foreach (var item in Items) @@ -113,15 +114,18 @@ namespace QuestPDF.Elements Offset = new Position(0, topOffset) }); + if (measurement.Width > targetWidth) + targetWidth = measurement.Width; + if (measurement.Type == SpacePlanType.PartialRender) break; topOffset += measurement.Height + Spacing; } - var targetWidth = commands.Select(x => x.Size.Width).DefaultIfEmpty(0).Max(); - commands.ForEach(x => x.Size = new Size(targetWidth, x.Size.Height)); - + foreach (var command in commands) + command.Size = new Size(targetWidth, command.Size.Height); + return commands; } }