From 08fee9a284cc082822392b38574fd2d4b0afb843 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 6 Aug 2014 17:52:56 +0200 Subject: util/ForeignFifoBuffer: add method GetAvailable() --- src/util/DynamicFifoBuffer.hxx | 3 ++- src/util/ForeignFifoBuffer.hxx | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/util/DynamicFifoBuffer.hxx b/src/util/DynamicFifoBuffer.hxx index d441b4484..91cbbc4c7 100644 --- a/src/util/DynamicFifoBuffer.hxx +++ b/src/util/DynamicFifoBuffer.hxx @@ -54,6 +54,7 @@ public: using ForeignFifoBuffer::IsEmpty; using ForeignFifoBuffer::IsFull; + using ForeignFifoBuffer::GetAvailable; using ForeignFifoBuffer::Read; using ForeignFifoBuffer::Consume; using ForeignFifoBuffer::Write; @@ -73,7 +74,7 @@ public: /* we already have enough space */ return; - const size_type in_use = Read().size; + const size_type in_use = GetAvailable(); const size_type required_capacity = in_use + n; size_type new_capacity = GetCapacity(); do { diff --git a/src/util/ForeignFifoBuffer.hxx b/src/util/ForeignFifoBuffer.hxx index c119fb6d5..cd6fb6101 100644 --- a/src/util/ForeignFifoBuffer.hxx +++ b/src/util/ForeignFifoBuffer.hxx @@ -171,6 +171,10 @@ public: tail += n; } + constexpr size_type GetAvailable() const { + return tail - head; + } + /** * Return a buffer range which may be read. The buffer pointer is * writable, to allow modifications while parsing. -- cgit v1.2.3