aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util/CircularBuffer.hxx9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util/CircularBuffer.hxx b/src/util/CircularBuffer.hxx
index 67b60e198..0321b91f6 100644
--- a/src/util/CircularBuffer.hxx
+++ b/src/util/CircularBuffer.hxx
@@ -99,6 +99,15 @@ public:
}
/**
+ * Returns the number of elements stored in this buffer.
+ */
+ constexpr size_type GetSize() const {
+ return head <= tail
+ ? tail - head
+ : capacity - head + tail;
+ }
+
+ /**
* Prepares writing. Returns a buffer range which may be written.
* When you are finished, call Append().
*/