Author: tilman
Date: Mon Jan 5 20:27:23 2026
New Revision: 1931141
Log:
PDFBOX-5660: optimize, as suggested by Valery Bokov; closes #390
Modified:
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType5.java
Modified:
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType5.java
==============================================================================
---
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType5.java
Mon Jan 5 20:27:19 2026 (r1931140)
+++
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType5.java
Mon Jan 5 20:27:23 2026 (r1931141)
@@ -158,28 +158,32 @@ public class PDShadingType5 extends PDTr
{
Point2D[] ps = new Point2D[3]; // array will be shallow-cloned in
ShadedTriangle constructor
float[][] cs = new float[3][];
- List<ShadedTriangle> list = new ArrayList<>();
+ List<ShadedTriangle> list = new ArrayList<>((rowNum - 1) * (numPerRow
- 1));
for (int i = 0; i < rowNum - 1; i++)
{
for (int j = 0; j < numPerRow - 1; j++)
{
- ps[0] = latticeArray[i][j].point;
- ps[1] = latticeArray[i][j + 1].point;
- ps[2] = latticeArray[i + 1][j].point;
+ Vertex vertex1 = latticeArray[i][j];
+ Vertex vertex2 = latticeArray[i][j + 1];
+ Vertex vertex3 = latticeArray[i + 1][j];
+ Vertex vertex4 = latticeArray[i + 1][j + 1];
+ ps[0] = vertex1.point;
+ ps[1] = vertex2.point;
+ ps[2] = vertex3.point;
- cs[0] = latticeArray[i][j].color;
- cs[1] = latticeArray[i][j + 1].color;
- cs[2] = latticeArray[i + 1][j].color;
+ cs[0] = vertex1.color;
+ cs[1] = vertex2.color;
+ cs[2] = vertex3.color;
list.add(new ShadedTriangle(ps, cs));
- ps[0] = latticeArray[i][j + 1].point;
- ps[1] = latticeArray[i + 1][j].point;
- ps[2] = latticeArray[i + 1][j + 1].point;
+ ps[0] = vertex2.point;
+ ps[1] = vertex3.point;
+ ps[2] = vertex4.point;
- cs[0] = latticeArray[i][j + 1].color;
- cs[1] = latticeArray[i + 1][j].color;
- cs[2] = latticeArray[i + 1][j + 1].color;
+ cs[0] = vertex2.color;
+ cs[1] = vertex3.color;
+ cs[2] = vertex4.color;
list.add(new ShadedTriangle(ps, cs));
}