Commit 0b727f1b authored by Tebjan Halm's avatar Tebjan Halm Committed by GitHub
Browse files

Merge pull request #285 from LightningDragon/master

Added array caching to AddToPath for a significant performance increase.
parents df31b65d f1a927c0
...@@ -9,13 +9,17 @@ namespace Svg.Pathing ...@@ -9,13 +9,17 @@ namespace Svg.Pathing
public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath) public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath)
{ {
// Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure. // Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
if (graphicsPath.PointCount > 0 && !graphicsPath.PathPoints[0].Equals(graphicsPath.PathPoints[graphicsPath.PathPoints.Length - 1])) var pathPoints = graphicsPath.PathPoints;
if (pathPoints.Length > 0 && !pathPoints[0].Equals(pathPoints[pathPoints.Length - 1]))
{ {
int i = graphicsPath.PathTypes.Length - 1; var pathTypes = graphicsPath.PathTypes;
while (i >= 0 && graphicsPath.PathTypes[i] > 0) i--; int i = pathPoints.Length - 1;
while (i >= 0 && pathTypes[i] > 0) i--;
if (i < 0) i = 0; if (i < 0) i = 0;
graphicsPath.AddLine(graphicsPath.PathPoints[graphicsPath.PathPoints.Length - 1], graphicsPath.PathPoints[i]); graphicsPath.AddLine(pathPoints[pathPoints.Length - 1], pathPoints[i]);
} }
graphicsPath.CloseFigure(); graphicsPath.CloseFigure();
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment