fix: Eliminates string allocations while writing gump packets (#1017)
* Introduces `RawInterpolatedStringHandler` which is exactly the same as `DefaultInterpolatedStringHandler` except it _unsafely exposes_ it's `ReadOnlySpan<char>` buffer. This is useful for writing the string's data without actually building the string. * Uses this new string interpolation handler in `SpanWriter` to eliminate intermediate strings built. This is immensely useful in eliminating string allocations in writing Gump packets.
This commit is contained in:
parent
f7cbeacf48
commit
87b63b38a5
7 changed files with 674 additions and 43 deletions
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Server.Buffers;
|
||||
|
||||
|
|
@ -64,7 +63,7 @@ public struct PooledArraySpanFormattable : ISpanFormattable, IDisposable
|
|||
{
|
||||
if (_arrayToReturnToPool != null)
|
||||
{
|
||||
ArrayPool<char>.Shared.Return(_arrayToReturnToPool);
|
||||
STArrayPool<char>.Shared.Return(_arrayToReturnToPool);
|
||||
_arrayToReturnToPool = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue