fix(core): Converts book packets (#413)

- [X] Splits out BaseBook
- [X] Converts book packets
- [X] Makes FixHtml faster
This commit is contained in:
Kamron Batman 2021-01-16 18:49:53 -08:00 • committed by GitHub
parent 3d7c4583a8
commit a146955f6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 427 additions and 228 deletions

View file

@ -10,6 +10,7 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Xml;
using Microsoft.Toolkit.HighPerformance.Extensions;
using Server.Buffers;
using Server.Network;
using Server.Random;
@ -560,31 +561,10 @@ namespace Server
return "";
}
var hasOpen = str.ContainsOrdinal('<');
var hasClose = str.ContainsOrdinal('>');
var hasPound = str.ContainsOrdinal('#');
if (!hasOpen && !hasClose && !hasPound)
{
return str;
}
var sb = new StringBuilder(str);
if (hasOpen)
{
sb.Replace('<', '(');
}
if (hasClose)
{
sb.Replace('>', ')');
}
if (hasPound)
{
sb.Replace('#', '-');
}
using var sb = new ValueStringBuilder(str, stackalloc char[Math.Min(40960, str.Length)]);
ReadOnlySpan<char> invalid = stackalloc []{ '<', '>', '#' };
ReadOnlySpan<char> replacement = stackalloc []{ '(', ')', '-' };
sb.ReplaceAny(invalid, replacement, 0, sb.Length);
return sb.ToString();
}