mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
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:

committed by
Patrik Svensson

parent
6f16081f42
commit
254880e93a
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user