fix(core): Converts book packets (#413)
- [X] Splits out BaseBook - [X] Converts book packets - [X] Makes FixHtml faster
This commit is contained in:
parent
3d7c4583a8
commit
a146955f6c
8 changed files with 427 additions and 228 deletions
|
|
@ -14,6 +14,17 @@ namespace Server.Buffers
|
|||
private char[]? _arrayToReturnToPool;
|
||||
private Span<char> _chars;
|
||||
|
||||
// If this ctor is used, you cannot pass in stackalloc ROS for append/replace.
|
||||
public ValueStringBuilder(ReadOnlySpan<char> initialString) : this(initialString.Length)
|
||||
{
|
||||
Append(initialString);
|
||||
}
|
||||
|
||||
public ValueStringBuilder(ReadOnlySpan<char> initialString, Span<char> initialBuffer) : this(initialBuffer)
|
||||
{
|
||||
Append(initialString);
|
||||
}
|
||||
|
||||
public ValueStringBuilder(Span<char> initialBuffer)
|
||||
{
|
||||
_arrayToReturnToPool = null;
|
||||
|
|
@ -21,6 +32,7 @@ namespace Server.Buffers
|
|||
Length = 0;
|
||||
}
|
||||
|
||||
// If this ctor is used, you cannot pass in stackalloc ROS for append/replace.
|
||||
public ValueStringBuilder(int initialCapacity)
|
||||
{
|
||||
_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity);
|
||||
|
|
@ -297,6 +309,37 @@ namespace Server.Buffers
|
|||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReplaceAny(ReadOnlySpan<char> oldChars, ReadOnlySpan<char> newChars, int startIndex, int count)
|
||||
{
|
||||
int currentLength = Length;
|
||||
if ((uint)startIndex > (uint)currentLength)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(startIndex));
|
||||
}
|
||||
|
||||
if (count < 0 || startIndex > currentLength - count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
|
||||
var slice = _chars;
|
||||
|
||||
while (true)
|
||||
{
|
||||
var indexOf = slice.IndexOfAny(oldChars);
|
||||
if (indexOf == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var chr = slice[indexOf];
|
||||
|
||||
slice[indexOf] = newChars[oldChars.IndexOf(chr)];
|
||||
slice = slice.Slice(indexOf + 1);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Replace(char oldChar, char newChar, int startIndex, int count)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue