util/{Const,Writable}Buffer, ...: rename IsEmpty() to empty(), imitating STL
This commit is contained in:
@@ -112,7 +112,7 @@ public:
|
||||
* Returns true if no memory was allocated so far.
|
||||
*/
|
||||
constexpr bool empty() const {
|
||||
return buffer.IsEmpty();
|
||||
return buffer.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -90,7 +90,7 @@ public:
|
||||
return capacity;
|
||||
}
|
||||
|
||||
constexpr bool IsEmpty() const {
|
||||
constexpr bool empty() const {
|
||||
return head == tail;
|
||||
}
|
||||
|
||||
|
@@ -84,7 +84,7 @@ struct ConstBuffer<void> {
|
||||
return data != nullptr;
|
||||
}
|
||||
|
||||
constexpr bool IsEmpty() const {
|
||||
constexpr bool empty() const {
|
||||
return size == 0;
|
||||
}
|
||||
};
|
||||
@@ -167,7 +167,7 @@ struct ConstBuffer {
|
||||
return data != nullptr;
|
||||
}
|
||||
|
||||
constexpr bool IsEmpty() const {
|
||||
constexpr bool empty() const {
|
||||
return size == 0;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ struct ConstBuffer {
|
||||
#endif
|
||||
reference_type front() const {
|
||||
#ifndef NDEBUG
|
||||
assert(!IsEmpty());
|
||||
assert(!empty());
|
||||
#endif
|
||||
return data[0];
|
||||
}
|
||||
@@ -231,7 +231,7 @@ struct ConstBuffer {
|
||||
#endif
|
||||
reference_type back() const {
|
||||
#ifndef NDEBUG
|
||||
assert(!IsEmpty());
|
||||
assert(!empty());
|
||||
#endif
|
||||
return data[size - 1];
|
||||
}
|
||||
@@ -242,7 +242,7 @@ struct ConstBuffer {
|
||||
*/
|
||||
void pop_front() {
|
||||
#ifndef NDEBUG
|
||||
assert(!IsEmpty());
|
||||
assert(!empty());
|
||||
#endif
|
||||
|
||||
++data;
|
||||
@@ -255,7 +255,7 @@ struct ConstBuffer {
|
||||
*/
|
||||
void pop_back() {
|
||||
#ifndef NDEBUG
|
||||
assert(!IsEmpty());
|
||||
assert(!empty());
|
||||
#endif
|
||||
|
||||
--size;
|
||||
|
@@ -53,7 +53,7 @@ public:
|
||||
/**
|
||||
* Is the first part empty?
|
||||
*/
|
||||
bool IsEmpty() const {
|
||||
bool empty() const {
|
||||
assert(IsDefined());
|
||||
|
||||
return *first == 0;
|
||||
|
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
using ForeignFifoBuffer<T>::GetCapacity;
|
||||
using ForeignFifoBuffer<T>::Clear;
|
||||
using ForeignFifoBuffer<T>::IsEmpty;
|
||||
using ForeignFifoBuffer<T>::empty;
|
||||
using ForeignFifoBuffer<T>::IsFull;
|
||||
using ForeignFifoBuffer<T>::GetAvailable;
|
||||
using ForeignFifoBuffer<T>::Read;
|
||||
|
@@ -134,7 +134,7 @@ public:
|
||||
head = tail = 0;
|
||||
}
|
||||
|
||||
constexpr bool IsEmpty() const {
|
||||
constexpr bool empty() const {
|
||||
return head == tail;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
* When you are finished, call Append().
|
||||
*/
|
||||
Range Write() {
|
||||
if (IsEmpty())
|
||||
if (empty())
|
||||
Clear();
|
||||
else if (tail == capacity)
|
||||
Shift();
|
||||
|
@@ -32,10 +32,10 @@ PeakBuffer::~PeakBuffer()
|
||||
}
|
||||
|
||||
bool
|
||||
PeakBuffer::IsEmpty() const noexcept
|
||||
PeakBuffer::empty() const noexcept
|
||||
{
|
||||
return (normal_buffer == nullptr || normal_buffer->IsEmpty()) &&
|
||||
(peak_buffer == nullptr || peak_buffer->IsEmpty());
|
||||
return (normal_buffer == nullptr || normal_buffer->empty()) &&
|
||||
(peak_buffer == nullptr || peak_buffer->empty());
|
||||
}
|
||||
|
||||
WritableBuffer<void>
|
||||
@@ -43,13 +43,13 @@ PeakBuffer::Read() const noexcept
|
||||
{
|
||||
if (normal_buffer != nullptr) {
|
||||
const auto p = normal_buffer->Read();
|
||||
if (!p.IsEmpty())
|
||||
if (!p.empty())
|
||||
return p.ToVoid();
|
||||
}
|
||||
|
||||
if (peak_buffer != nullptr) {
|
||||
const auto p = peak_buffer->Read();
|
||||
if (!p.IsEmpty())
|
||||
if (!p.empty())
|
||||
return p.ToVoid();
|
||||
}
|
||||
|
||||
@@ -59,14 +59,14 @@ PeakBuffer::Read() const noexcept
|
||||
void
|
||||
PeakBuffer::Consume(size_t length) noexcept
|
||||
{
|
||||
if (normal_buffer != nullptr && !normal_buffer->IsEmpty()) {
|
||||
if (normal_buffer != nullptr && !normal_buffer->empty()) {
|
||||
normal_buffer->Consume(length);
|
||||
return;
|
||||
}
|
||||
|
||||
if (peak_buffer != nullptr && !peak_buffer->IsEmpty()) {
|
||||
if (peak_buffer != nullptr && !peak_buffer->empty()) {
|
||||
peak_buffer->Consume(length);
|
||||
if (peak_buffer->IsEmpty()) {
|
||||
if (peak_buffer->empty()) {
|
||||
delete peak_buffer;
|
||||
peak_buffer = nullptr;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ AppendTo(DynamicFifoBuffer<uint8_t> &buffer,
|
||||
|
||||
do {
|
||||
const auto p = buffer.Write();
|
||||
if (p.IsEmpty())
|
||||
if (p.empty())
|
||||
break;
|
||||
|
||||
const size_t nbytes = std::min(length, p.size);
|
||||
@@ -107,7 +107,7 @@ PeakBuffer::Append(const void *data, size_t length)
|
||||
if (length == 0)
|
||||
return true;
|
||||
|
||||
if (peak_buffer != nullptr && !peak_buffer->IsEmpty()) {
|
||||
if (peak_buffer != nullptr && !peak_buffer->empty()) {
|
||||
size_t nbytes = AppendTo(*peak_buffer, data, length);
|
||||
return nbytes == length;
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ public:
|
||||
PeakBuffer &operator=(const PeakBuffer &) = delete;
|
||||
|
||||
gcc_pure
|
||||
bool IsEmpty() const noexcept;
|
||||
bool empty() const noexcept;
|
||||
|
||||
gcc_pure
|
||||
WritableBuffer<void> Read() const noexcept;
|
||||
|
@@ -79,7 +79,7 @@ public:
|
||||
return buffer.size();
|
||||
}
|
||||
|
||||
bool IsEmpty() const {
|
||||
bool empty() const {
|
||||
return n_allocated == 0;
|
||||
}
|
||||
|
||||
|
@@ -78,7 +78,7 @@ public:
|
||||
head = tail = 0;
|
||||
}
|
||||
|
||||
bool IsEmpty() const {
|
||||
bool empty() const {
|
||||
return head == tail;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
* When you are finished, call Append().
|
||||
*/
|
||||
Range Write() {
|
||||
if (IsEmpty())
|
||||
if (empty())
|
||||
Clear();
|
||||
else if (tail == size)
|
||||
Shift();
|
||||
|
@@ -34,7 +34,7 @@ template<typename T>
|
||||
void
|
||||
BasicStringView<T>::StripLeft() noexcept
|
||||
{
|
||||
while (!IsEmpty() && IsWhitespaceOrNull(front()))
|
||||
while (!empty() && IsWhitespaceOrNull(front()))
|
||||
pop_front();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ template<typename T>
|
||||
void
|
||||
BasicStringView<T>::StripRight() noexcept
|
||||
{
|
||||
while (!IsEmpty() && IsWhitespaceOrNull(back()))
|
||||
while (!empty() && IsWhitespaceOrNull(back()))
|
||||
pop_back();
|
||||
}
|
||||
|
||||
|
@@ -58,7 +58,7 @@ struct BasicStringView : ConstBuffer<T> {
|
||||
constexpr BasicStringView(std::nullptr_t n) noexcept
|
||||
:ConstBuffer<T>(n) {}
|
||||
|
||||
using ConstBuffer<T>::IsEmpty;
|
||||
using ConstBuffer<T>::empty;
|
||||
using ConstBuffer<T>::front;
|
||||
using ConstBuffer<T>::back;
|
||||
using ConstBuffer<T>::pop_front;
|
||||
|
@@ -41,7 +41,7 @@ gcc_pure
|
||||
static bool
|
||||
IsValidScheme(StringView p) noexcept
|
||||
{
|
||||
if (p.IsEmpty() || !IsValidSchemeStart(p.front()))
|
||||
if (p.empty() || !IsValidSchemeStart(p.front()))
|
||||
return false;
|
||||
|
||||
for (size_t i = 1; i < p.size; ++i)
|
||||
|
@@ -76,7 +76,7 @@ struct WritableBuffer<void> {
|
||||
return data != nullptr;
|
||||
}
|
||||
|
||||
constexpr bool IsEmpty() const {
|
||||
constexpr bool empty() const {
|
||||
return size == 0;
|
||||
}
|
||||
};
|
||||
@@ -161,7 +161,7 @@ struct WritableBuffer {
|
||||
return data != nullptr;
|
||||
}
|
||||
|
||||
constexpr bool IsEmpty() const {
|
||||
constexpr bool empty() const {
|
||||
return size == 0;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ struct WritableBuffer {
|
||||
#endif
|
||||
reference_type front() const {
|
||||
#ifndef NDEBUG
|
||||
assert(!IsEmpty());
|
||||
assert(!empty());
|
||||
#endif
|
||||
return data[0];
|
||||
}
|
||||
@@ -215,7 +215,7 @@ struct WritableBuffer {
|
||||
#endif
|
||||
reference_type back() const {
|
||||
#ifndef NDEBUG
|
||||
assert(!IsEmpty());
|
||||
assert(!empty());
|
||||
#endif
|
||||
return data[size - 1];
|
||||
}
|
||||
@@ -225,7 +225,7 @@ struct WritableBuffer {
|
||||
* not actually modify the buffer). Buffer must not be empty.
|
||||
*/
|
||||
void pop_front() {
|
||||
assert(!IsEmpty());
|
||||
assert(!empty());
|
||||
|
||||
++data;
|
||||
--size;
|
||||
@@ -236,7 +236,7 @@ struct WritableBuffer {
|
||||
* not actually modify the buffer). Buffer must not be empty.
|
||||
*/
|
||||
void pop_back() {
|
||||
assert(!IsEmpty());
|
||||
assert(!empty());
|
||||
|
||||
--size;
|
||||
}
|
||||
|
Reference in New Issue
Block a user