Remove loop to calculate maximum (target) width, remove capturing lambda
This commit is contained in:
@@ -87,6 +87,7 @@ namespace QuestPDF.Elements
|
||||
private ICollection<ColumnItemRenderingCommand> PlanLayout(Size availableSpace)
|
||||
{
|
||||
var topOffset = 0f;
|
||||
var targetWidth = 0f;
|
||||
var commands = new List<ColumnItemRenderingCommand>();
|
||||
|
||||
foreach (var item in Items)
|
||||
@@ -113,14 +114,17 @@ 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user