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

@ -41,5 +41,56 @@ namespace Spectre.Console.Tests.Unit
result.ShouldBe("Hello 🌍!");
}
}
public sealed class Parsing
{
[Theory]
[InlineData(":", ":")]
[InlineData("::", "::")]
[InlineData(":::", ":::")]
[InlineData("::::", "::::")]
[InlineData("::i:", "::i:")]
[InlineData(":i:i:", ":i:i:")]
[InlineData("::globe_showing_europe_africa::", ":🌍:")]
[InlineData(":globe_showing_europe_africa::globe_showing_europe_africa:", "🌍🌍")]
[InlineData("::globe_showing_europe_africa:::test:::globe_showing_europe_africa:::", ":🌍::test::🌍::")]
public void Can_Handle_Different_Combinations(string markup, string expected)
{
// Given
var console = new FakeAnsiConsole(ColorSystem.Standard, AnsiSupport.Yes);
// When
console.Markup(markup);
// Then
console.Output.ShouldBe(expected);
}
[Fact]
public void Should_Leave_Single_Colons()
{
// Given
var console = new FakeAnsiConsole(ColorSystem.Standard, AnsiSupport.Yes);
// When
console.Markup("Hello :globe_showing_europe_africa:! Output: good");
// Then
console.Output.ShouldBe("Hello 🌍! Output: good");
}
[Fact]
public void Unknown_emojis_should_remain()
{
// Given
var console = new FakeAnsiConsole(ColorSystem.Standard, AnsiSupport.Yes);
// When
console.Markup("Hello :globe_showing_flat_earth:!");
// Then
console.Output.ShouldBe("Hello :globe_showing_flat_earth:!");
}
}
}
}