public unsafe void EnsureSpace(int length) { if (used + length > str.Length) { int newSize; checked { var minimumNewSize = length + used; do { newSize = used * 2; }while (newSize < minimumNewSize); } var newStr = ValueString.AllocateString(newSize); fixed(char *dest = newStr) fixed(char *source = str) { Buffer.MemoryCopy((void *)source, dest, newStr.Length * 2, used * 2); } str = newStr; } }
public void EnsureSpace(int length) { if (used + length > str.Length) { str = ValueString.AllocateString(Math.Max(length, blockSize)); used = 0; } }
public MultiValueStringBuilder(int blockSize) { this.blockSize = blockSize; this.str = ValueString.AllocateString(blockSize); }