diff options
author | Josh Blum | 2012-09-02 19:37:32 -0700 |
---|---|---|
committer | Josh Blum | 2012-09-02 19:37:32 -0700 |
commit | fb5c7144a4e9145612fd610fe5d9d2ede7697cc7 (patch) | |
tree | 70cc800bb6eafcae5a686d7ef0ea0aa356765ca4 | |
parent | 4bb71b3e25c55a28bdfd4447ec2bbb5c669a7c82 (diff) | |
download | sandhi-fb5c7144a4e9145612fd610fe5d9d2ede7697cc7.tar.gz sandhi-fb5c7144a4e9145612fd610fe5d9d2ede7697cc7.tar.bz2 sandhi-fb5c7144a4e9145612fd610fe5d9d2ede7697cc7.zip |
deeper thoughts about history in the input queues
-rw-r--r-- | lib/gras_impl/input_buffer_queues.hpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp index 8e1416a..4faa690 100644 --- a/lib/gras_impl/input_buffer_queues.hpp +++ b/lib/gras_impl/input_buffer_queues.hpp @@ -87,24 +87,20 @@ struct InputBufferQueues BuffInfo info; const tsbe::Buffer &buff = _queues[i].front(); - if (_history_bytes[i] != 0) + if (_offset_bytes[i] < _history_bytes[i]) { const tsbe::Buffer &hist_buff = _history_buffs[i]; + ASSERT(buff.get_length() >= _post_bytes[i]); if (_offset_bytes[i] == 0) { - info.mem = (char *)hist_buff.get_memory(); - info.len = hist_buff.get_length(); char *src_mem = ((char *)buff.get_memory()); - char *dst_mem = ((char *)info.mem) + _history_bytes[i]; + char *dst_mem = ((char *)hist_buff.get_memory()) + _history_bytes[i]; std::memcpy(dst_mem, src_mem, _post_bytes[i]); } - else if (_offset_bytes[i] < _history_bytes[i]) //caller left us a partial - { - info.mem = (char *)hist_buff.get_memory() + _offset_bytes[i]; - info.len = hist_buff.get_length() - _offset_bytes[i]; - } + info.mem = (char *)hist_buff.get_memory() + _offset_bytes[i]; + info.len = hist_buff.get_length() - _offset_bytes[i]; } else @@ -123,13 +119,11 @@ struct InputBufferQueues * If we were operating in a mini history buffer, do nothing. * Otherwise, check if the input buffer was entirely consumed. * If so, pop the input buffer, copy the tail end of the buffer - * into the mini history buffer, nd reset the offset condition. + * into the mini history buffer, and reset the offset condition. */ inline void pop(const size_t i, const size_t bytes_consumed) { - const bool in_history = _offset_bytes[i] < _history_bytes[i]; - _offset_bytes[i] += bytes_consumed; - if (in_history) return; + _offset_bytes[i] += bytes_consumed + _history_bytes[i]; //if totally consumed, memcpy history and pop const tsbe::Buffer &buff = _queues[i].front(); |