diff options
author | Max Kellermann <max@musicpd.org> | 2019-08-03 12:53:23 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-08-03 12:53:23 +0200 |
commit | a90685d6cf6300165d5ad59c160759f7f38cd6c0 (patch) | |
tree | 960a1ba56ec91941e676eaf3fffb0c1c108f2b7d /src/util | |
parent | fe2f8c088aa6a4ae97283e0b81a76bbbc51132fc (diff) | |
parent | ae19bda1f297727e47b867ca8394692682553958 (diff) |
Merge tag 'v0.21.12'
release v0.21.12
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/Compiler.h | 12 | ||||
-rw-r--r-- | src/util/StaticFifoBuffer.hxx | 22 |
2 files changed, 13 insertions, 21 deletions
diff --git a/src/util/Compiler.h b/src/util/Compiler.h index 275c04262..e441d3835 100644 --- a/src/util/Compiler.h +++ b/src/util/Compiler.h @@ -57,18 +57,6 @@ (GCC_VERSION > 0 && CLANG_VERSION == 0 && \ GCC_VERSION < GCC_MAKE_VERSION(major, minor, 0)) -#ifdef __clang__ -# if __clang_major__ < 3 -# error Sorry, your clang version is too old. You need at least version 3.1. -# endif -#elif defined(__GNUC__) -# if GCC_OLDER_THAN(6,0) -# error Sorry, your gcc version is too old. You need at least version 6.0. -# endif -#else -# warning Untested compiler. Use at your own risk! -#endif - /** * Are we building with the specified version of clang or newer? */ diff --git a/src/util/StaticFifoBuffer.hxx b/src/util/StaticFifoBuffer.hxx index 076a573bb..615f92e3f 100644 --- a/src/util/StaticFifoBuffer.hxx +++ b/src/util/StaticFifoBuffer.hxx @@ -56,11 +56,11 @@ protected: T data[size]; public: - constexpr size_type GetCapacity() const { + constexpr size_type GetCapacity() const noexcept { return size; } - void Shift() { + void Shift() noexcept { if (head == 0) return; @@ -74,15 +74,15 @@ public: head = 0; } - void Clear() { + void Clear() noexcept { head = tail = 0; } - bool empty() const { + constexpr bool empty() const noexcept { return head == tail; } - bool IsFull() const { + constexpr bool IsFull() const noexcept { return head == 0 && tail == size; } @@ -90,7 +90,7 @@ public: * Prepares writing. Returns a buffer range which may be written. * When you are finished, call Append(). */ - Range Write() { + Range Write() noexcept { if (empty()) Clear(); else if (tail == size) @@ -103,7 +103,7 @@ public: * Expands the tail of the buffer, after data has been written to * the buffer returned by Write(). */ - void Append(size_type n) { + void Append(size_type n) noexcept { assert(tail <= size); assert(n <= size); assert(tail + n <= size); @@ -111,18 +111,22 @@ public: tail += n; } + constexpr size_type GetAvailable() const noexcept { + return tail - head; + } + /** * Return a buffer range which may be read. The buffer pointer is * writable, to allow modifications while parsing. */ - Range Read() { + constexpr Range Read() noexcept { return Range(data + head, tail - head); } /** * Marks a chunk as consumed. */ - void Consume(size_type n) { + void Consume(size_type n) noexcept { assert(tail <= size); assert(head <= tail); assert(n <= tail); |