Skip to content

Commit

Permalink
Improve presized allocation of lists
Browse files Browse the repository at this point in the history
Autoported commit.
Original commit hash: [15951163c]
  • Loading branch information
guustysebie authored and iText-CI committed May 21, 2024
1 parent f1c93ee commit 8529d8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public static Border GetCollapsedBorder(Border cellBorder, Border tableBorder) {

public static IList<Border> GetCollapsedList(IList<Border> innerList, IList<Border> outerList) {
int size = Math.Min(null == innerList ? 0 : innerList.Count, null == outerList ? 0 : outerList.Count);
IList<Border> collapsedList = new List<Border>();
IList<Border> collapsedList = new List<Border>(size);
for (int i = 0; i < size; i++) {
collapsedList.Add(GetCollapsedBorder(innerList[i], outerList[i]));
}
Expand Down
6 changes: 5 additions & 1 deletion itext/itext.layout/itext/layout/renderer/TableBorderUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ public static IList<Border> CreateAndFillBorderList(Border border, int size) {

public static IList<Border> CreateAndFillBorderList(IList<Border> originalList, Border borderToCollapse, int
size) {
IList<Border> borderList = new List<Border>();
IList<Border> borderList;
if (null != originalList) {
borderList = new List<Border>(originalList.Count + size);
borderList.AddAll(originalList);
}
else {
borderList = new List<Border>(size);
}
while (borderList.Count < size) {
borderList.Add(borderToCollapse);
}
Expand Down
2 changes: 1 addition & 1 deletion port-hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cfc00f2365e87e6de0128fe028076bf696694a2c
15951163c968bb91b805b915388550f2e4296bcf

0 comments on commit 8529d8f

Please sign in to comment.