Exemplo n.º 1
0
            static void Resize(UnsafeBufferWriter <T> self, int requestedSize)
            {
                var newCapacity = Math.Max(4, Math.Max(requestedSize + self._count, self._buffer.Length * 2));
                var newBuffer   = new UnsafeRawArray <T>(newCapacity, false);

                try {
                    self._buffer.AsSpan(0, self._count).CopyTo(newBuffer.AsSpan());
                }
                catch {
                    newBuffer.Dispose();
                    throw;
                }
                self._buffer.Dispose();
                self._buffer = newBuffer;
            }
Exemplo n.º 2
0
 public UnsafeBufferWriter(int capacity)
 {
     _buffer = new UnsafeRawArray <T>(capacity, false);
 }
Exemplo n.º 3
0
 public UnsafeBufferWriter()
 {
     _buffer = UnsafeRawArray <T> .Empty;
 }