From ff8882976de98e67eb05c24a36f6fa3c7602e35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 4 Oct 2016 17:50:13 +0200 Subject: [PATCH] Fix BatchBuffer.read. --- source/vibe/internal/array.d | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/vibe/internal/array.d b/source/vibe/internal/array.d index 6e2024c..c6de5d9 100644 --- a/source/vibe/internal/array.d +++ b/source/vibe/internal/array.d @@ -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 read(T[] dst) { assert(length() >= dst.length); - dst[] = m_buffer[0 .. m_fill]; - m_fill = 0; + dst[] = m_buffer[m_first .. m_first + dst.length]; + m_first += dst.length; + assert(m_first <= m_fill); + if (m_first == m_fill) m_first = m_fill = 0; } }