Replaces emoji regex with ReadOnlySpan implementation

The RegEx runtime perf was never anything noticeable - it was the startup time that was eating over a third of time during initialization.

This shaves 200ms off the startup time.
This commit is contained in:
Phil Scott
2021-04-02 21:48:30 -04:00
committed by Patrik Svensson
parent 6f16081f42
commit 254880e93a
4 changed files with 145 additions and 17 deletions

View File

@ -1,3 +1,4 @@
using System;
using System.Globalization;
using System.Text;
@ -25,5 +26,16 @@ namespace Spectre.Console
return builder.Append(value);
}
public static void AppendSpan(this StringBuilder builder, ReadOnlySpan<char> span)
{
// NetStandard 2 lacks the override for StringBuilder to add the span. We'll need to convert the span
// to a string for it, but for .NET 5.0 we'll use the override.
#if NETSTANDARD2_0
builder.Append(span.ToString());
#else
builder.Append(span);
#endif
}
}
}