mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-04 05:44:50 +00:00
Avoid allocating strings for known emphasis character fallbacks
This commit is contained in:
@@ -69,7 +69,21 @@ public class EmphasisDelimiterInline : DelimiterInline
|
||||
|
||||
public override string ToLiteral()
|
||||
{
|
||||
return DelimiterCount > 0 ? new string(DelimiterChar, DelimiterCount) : string.Empty;
|
||||
if (DelimiterCount == 1)
|
||||
{
|
||||
return DelimiterChar switch
|
||||
{
|
||||
'*' => "*",
|
||||
'_' => "_",
|
||||
'~' => "~",
|
||||
'^' => "^",
|
||||
'+' => "+",
|
||||
'=' => "=",
|
||||
_ => DelimiterChar.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
return new string(DelimiterChar, DelimiterCount);
|
||||
}
|
||||
|
||||
public LiteralInline AsLiteralInline()
|
||||
|
||||
Reference in New Issue
Block a user