Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorPilley committed Nov 21, 2024
1 parent 3ff1ab0 commit 049da93
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/PhoneNumbers/Formatters/PhoneNumberFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,9 @@ protected static string FormatInternational(
Span<char> ar = stackalloc char[arSize];
var arPos = 0;

if (outputPrefix is not null)
{
foreach (var c in outputPrefix)
{
ar[arPos++] = c;
}
}

ar.Append(ref arPos, outputPrefix);
ar[arPos++] = Chars.Plus;

foreach (var c in phoneNumber.Country.CallingCode)
{
ar[arPos++] = c;
}
ar.Append(ref arPos, phoneNumber.Country.CallingCode);

if (charBetweenCallingCodeAndNsn != Chars.Null)
{
Expand Down
18 changes: 18 additions & 0 deletions src/PhoneNumbers/FrameworkExtensions/SpanExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace PhoneNumbers;

/// <summary>
/// A class containing extension methods for the <see cref="ParseOptions"/> class.
/// </summary>
internal static class SpanExtensions
{
internal static void Append<T>(this ref Span<T> ar, ref int arPos, IEnumerable<T>? input)
{
if (input is not null)
{
foreach (var value in input)
{
ar[arPos++] = value;
}
}
}
}

0 comments on commit 049da93

Please sign in to comment.