summaryrefslogtreecommitdiff
path: root/lib/gras_impl
diff options
context:
space:
mode:
authorJosh Blum2012-11-09 23:03:34 -0800
committerJosh Blum2012-11-09 23:03:34 -0800
commitf27f557ee5b567bc934a4d8cab3bc112c5898204 (patch)
treeeeb2670c23fbf704b25346a5e5a2bce3d54a0207 /lib/gras_impl
parent6779b36583be0d54cee2fb3931dfd31dcde541f6 (diff)
downloadsandhi-f27f557ee5b567bc934a4d8cab3bc112c5898204.tar.gz
sandhi-f27f557ee5b567bc934a4d8cab3bc112c5898204.tar.bz2
sandhi-f27f557ee5b567bc934a4d8cab3bc112c5898204.zip
input buffers deal with empty buffers
Diffstat (limited to 'lib/gras_impl')
-rw-r--r--lib/gras_impl/input_buffer_queues.hpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp
index 323b5b6..d216cbe 100644
--- a/lib/gras_impl/input_buffer_queues.hpp
+++ b/lib/gras_impl/input_buffer_queues.hpp
@@ -60,6 +60,7 @@ struct InputBufferQueues
GRAS_FORCE_INLINE void push(const size_t i, const SBuffer &buffer)
{
ASSERT(not _queues[i].full());
+ if (buffer.length == 0) return;
_queues[i].push_back(buffer);
_enqueued_bytes[i] += _queues[i].back().length;
__update(i);
@@ -201,14 +202,16 @@ GRAS_FORCE_INLINE void InputBufferQueues::accumulate(const size_t i, const size_
GRAS_FORCE_INLINE void InputBufferQueues::consume(const size_t i, const size_t bytes_consumed)
{
+ SBuffer &front = _queues[i].front();
+
//assert that we dont consume past the bounds of the buffer
- ASSERT(_queues[i].front().length >= bytes_consumed);
+ ASSERT(front.length >= bytes_consumed);
//update bounds on the current buffer
- _queues[i].front().offset += bytes_consumed;
- _queues[i].front().length -= bytes_consumed;
-
- ASSERT(_queues[i].front().offset <= _queues[i].front().get_actual_length());
+ front.offset += bytes_consumed;
+ front.length -= bytes_consumed;
+ ASSERT(front.offset <= front.get_actual_length());
+ if (front.length == 0) _queues[i].pop_front();
//update the number of bytes in this queue
ASSERT(_enqueued_bytes[i] >= bytes_consumed);