Beispiel #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;
            }
Beispiel #2
0
 public UnsafeBufferWriter(int capacity)
 {
     _buffer = new UnsafeRawArray <T>(capacity, false);
 }
Beispiel #3
0
 public UnsafeBufferWriter()
 {
     _buffer = UnsafeRawArray <T> .Empty;
 }