diff --git a/src/Avalonia.Visuals/Media/PathMarkupParser.cs b/src/Avalonia.Visuals/Media/PathMarkupParser.cs
index e17aafeda3..41cd95d319 100644
--- a/src/Avalonia.Visuals/Media/PathMarkupParser.cs
+++ b/src/Avalonia.Visuals/Media/PathMarkupParser.cs
@@ -5,9 +5,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
using Avalonia.Platform;
namespace Avalonia.Media
@@ -70,17 +67,6 @@ namespace Avalonia.Media
Close
}
- ///
- /// Parses the specified path data and writes the result to the geometryContext of this instance.
- ///
- /// The path data.
- public void Parse(string pathData)
- {
- var tokens = ParseTokens(pathData);
-
- CreateGeometry(tokens);
- }
-
void IDisposable.Dispose()
{
Dispose(true);
@@ -101,17 +87,6 @@ namespace Avalonia.Media
_isDisposed = true;
}
- private static IEnumerable ParseTokens(string s)
- {
- var commands = new List();
- var span = s.AsSpan();
- while (!span.IsEmpty)
- {
- commands.Add(CommandToken.Parse(ref span));
- }
- return commands;
- }
-
private static Point MirrorControlPoint(Point controlPoint, Point center)
{
var dir = controlPoint - center;
@@ -119,15 +94,21 @@ namespace Avalonia.Media
return center + -dir;
}
- private void CreateGeometry(IEnumerable commandTokens)
+ ///
+ /// Parses the specified path data and writes the result to the geometryContext of this instance.
+ ///
+ /// The path data.
+ public void Parse(string pathData)
{
+ var span = pathData.AsSpan();
_currentPoint = new Point();
- foreach (var commandToken in commandTokens)
+ while(!span.IsEmpty)
{
+ var commandToken = CommandToken.Parse(ref span);
try
{
- while (true)
+ do
{
switch (commandToken.Command)
{
@@ -169,14 +150,7 @@ namespace Avalonia.Media
default:
throw new NotSupportedException("Unsupported command");
}
-
- if (commandToken.HasImplicitCommands)
- {
- continue;
- }
-
- break;
- }
+ } while (commandToken.HasImplicitCommands);
}
catch (InvalidDataException)
{
@@ -235,11 +209,6 @@ namespace Avalonia.Media
CreateFigure();
- if (!commandToken.HasImplicitCommands)
- {
- return;
- }
-
while (commandToken.HasImplicitCommands)
{
AddLine(commandToken);