Browse Source

Remove LINQ usage.

pull/1685/head
Jeremy Koritzinsky 8 years ago
parent
commit
e2f5453798
  1. 51
      src/Avalonia.Visuals/Media/PathMarkupParser.cs

51
src/Avalonia.Visuals/Media/PathMarkupParser.cs

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

Loading…
Cancel
Save