diff --git a/Assets/Plugins/StringFormatter/StringFormatter.cs b/Assets/Plugins/StringFormatter/StringFormatter.cs index 358d56c..0f47dc3 100644 --- a/Assets/Plugins/StringFormatter/StringFormatter.cs +++ b/Assets/Plugins/StringFormatter/StringFormatter.cs @@ -410,8 +410,16 @@ namespace System.Text.Formatting { [MethodImpl(MethodImplOptions.AggressiveInlining)] void CheckCapacity (int count) { - if (currentCount + count > buffer.Length) - Array.Resize(ref buffer, buffer.Length * 2); + int newCount = currentCount + count; + if (newCount > buffer.Length) { + int newCapacity = buffer.Length * 2; + if (newCapacity < newCount) newCapacity = newCount; + char[] newBuffer = new char[newCapacity]; + fixed (void* nptr = newBuffer, ptr = buffer) { + Unsafe.CopyBlock(nptr, ptr, (uint)(currentCount * sizeof(char))); + } + buffer = newBuffer; + } } bool AppendSegment(ref char* currRef, char* end, char* dest, ref int prevArgIndex, ref T args) where T : IArgSet {