Skip to content

Commit 34e3b2b

Browse files
committed
PDFBOX-5660: optimize, as suggested by Valery Bokov; closes #402
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1931520 13f79535-47bb-0310-9956-ffa450edef68
1 parent 67e94ee commit 34e3b2b

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadedTriangle.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,23 @@ class ShadedTriangle
6464

6565
if (degree == 2)
6666
{
67-
if (overlaps(corner[1], corner[2]) && !overlaps(corner[0], corner[2]))
67+
Point2D corner0 = corner[0];
68+
Point2D corner1 = corner[1];
69+
Point2D corner2 = corner[2];
70+
if (overlaps(corner1, corner2) && !overlaps(corner0, corner2))
6871
{
69-
Point p0 = new Point((int) Math.round(corner[0].getX()),
70-
(int) Math.round(corner[0].getY()));
71-
Point p1 = new Point((int) Math.round(corner[2].getX()),
72-
(int) Math.round(corner[2].getY()));
72+
Point p0 = new Point((int) Math.round(corner0.getX()),
73+
(int) Math.round(corner0.getY()));
74+
Point p1 = new Point((int) Math.round(corner2.getX()),
75+
(int) Math.round(corner2.getY()));
7376
line = new Line(p0, p1, color[0], color[2]);
7477
}
7578
else
7679
{
77-
Point p0 = new Point((int) Math.round(corner[1].getX()),
78-
(int) Math.round(corner[1].getY()));
79-
Point p1 = new Point((int) Math.round(corner[2].getX()),
80-
(int) Math.round(corner[2].getY()));
80+
Point p0 = new Point((int) Math.round(corner1.getX()),
81+
(int) Math.round(corner1.getY()));
82+
Point p1 = new Point((int) Math.round(corner2.getX()),
83+
(int) Math.round(corner2.getY()));
8184
line = new Line(p0, p1, color[1], color[2]);
8285
}
8386
}

0 commit comments

Comments
 (0)