Browse Source

Optimized InternalLine

Martin Edlund 5 years ago
parent
commit
9988b5b6e0
1 changed files with 4 additions and 10 deletions
  1. 4 10
      SketchAssistant/SketchAssistantWPF/InternalLine.cs

+ 4 - 10
SketchAssistant/SketchAssistantWPF/InternalLine.cs

@@ -117,16 +117,10 @@ namespace SketchAssistantWPF
         /// </summary>
         private void CleanPoints()
         {
-            if (linePoints.Count > 1)
+            if (linePoints.Any())
             {
-                //if this is a point or not
-                var localIsPoint = true;
                 //check if its a point
-                foreach(Point p in linePoints)
-                {
-                    if (p.X != linePoints[0].X || p.Y != linePoints[0].Y)
-                        localIsPoint = false;
-                }
+                var localIsPoint = linePoints.All(o => o.X == linePoints.First().X && o.Y == linePoints.First().Y);
                 if (!localIsPoint) {
                     List<Point> newList = new List<Point>();
                     List<Point> tempList = new List<Point>();
@@ -162,8 +156,8 @@ namespace SketchAssistantWPF
                 else
                 {
                     isPoint = true;
-                    point = linePoints[0];
-                    linePoints = new List<Point>();
+                    point = linePoints.First();
+                    linePoints.Clear();
                     linePoints.Add(point);
                 }
             }