Fix BatchBuffer.read.

This commit is contained in:
Sönke Ludwig 2016-10-04 17:50:13 +02:00
parent 19f796af9f
commit ff8882976d

View file

@ -575,8 +575,10 @@ struct BatchBuffer(T, size_t N = 0) {
void putN(T[] elems) { assert(empty && elems.length <= m_buffer.length); m_buffer[0 .. elems.length] = elems[]; m_fill = elems.length; } void putN(T[] elems) { assert(empty && elems.length <= m_buffer.length); m_buffer[0 .. elems.length] = elems[]; m_fill = elems.length; }
void read(T[] dst) { void read(T[] dst) {
assert(length() >= dst.length); assert(length() >= dst.length);
dst[] = m_buffer[0 .. m_fill]; dst[] = m_buffer[m_first .. m_first + dst.length];
m_fill = 0; m_first += dst.length;
assert(m_first <= m_fill);
if (m_first == m_fill) m_first = m_fill = 0;
} }
} }