Skip to content

Commit f1cfb42

Browse files
Use span slice instead of substring in AbbreviatedGeometryParser.ReadNumber (#6272)
* Use span slice instead of substring in AbbreviatedGeometryParser.ReadNumber * Update src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ParsersCommon.cs Co-authored-by: ThomasGoulet73 <[email protected]> Co-authored-by: ThomasGoulet73 <[email protected]>
1 parent acbb3a8 commit f1cfb42

File tree

1 file changed

+7
-5
lines changed
  • src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media

1 file changed

+7
-5
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ParsersCommon.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,13 @@ double ReadNumber(bool allowComma)
435435
}
436436
else
437437
{
438-
string subString = _pathString.Substring(start, _curIndex - start);
439-
440438
try
441439
{
442-
return System.Convert.ToDouble(subString, _formatProvider);
440+
#if NET
441+
return double.Parse(_pathString.AsSpan(start, _curIndex - start), provider: _formatProvider);
442+
#else
443+
return double.Parse(_pathString.Substring(start, _curIndex - start), provider: _formatProvider);
444+
#endif
443445
}
444446
catch (FormatException except)
445447
{
@@ -691,9 +693,9 @@ internal void ParseToGeometryContext(
691693
large,
692694
#if PBTCOMPILER
693695
sweep,
694-
#else
696+
#else
695697
sweep ? SweepDirection.Clockwise : SweepDirection.Counterclockwise,
696-
#endif
698+
#endif
697699
IsStroked,
698700
! IsSmoothJoin
699701
);

0 commit comments

Comments
 (0)