summaryrefslogtreecommitdiff
path: root/src/buffer.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-09-15 21:15:53 +0200
committerJoel Klinghed <the_jk@spawned.biz>2025-09-15 21:15:53 +0200
commitaa49abdf239bae6065fddd0839ec67a404c9748c (patch)
tree631fbb2df58aa35df3d60c65c037ef74b1807114 /src/buffer.cc
parentbf41a601fd0447bcf3a2937a595a1cd8ca5c1633 (diff)
Add .clang-format
Make it easier to keep a consistent style
Diffstat (limited to 'src/buffer.cc')
-rw-r--r--src/buffer.cc28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/buffer.cc b/src/buffer.cc
index 3073a45..18913a5 100644
--- a/src/buffer.cc
+++ b/src/buffer.cc
@@ -10,8 +10,7 @@ namespace {
class FixedBuffer : public Buffer {
public:
- explicit FixedBuffer(size_t size)
- : size_(size) {}
+ explicit FixedBuffer(size_t size) : size_(size) {}
void const* rptr(size_t& avail, size_t need) override {
if (rptr_ < wptr_) {
@@ -29,7 +28,8 @@ class FixedBuffer : public Buffer {
}
void consume(size_t size) override {
- if (size == 0) return;
+ if (size == 0)
+ return;
if (rptr_ < wptr_) {
assert(std::cmp_greater_equal(wptr_ - rptr_, size));
rptr_ += size;
@@ -68,7 +68,8 @@ class FixedBuffer : public Buffer {
}
void commit(size_t size) override {
- if (size == 0) return;
+ if (size == 0)
+ return;
if (wptr_ < rptr_) {
assert(std::cmp_greater_equal(rptr_ - wptr_, size));
wptr_ += size;
@@ -87,13 +88,9 @@ class FixedBuffer : public Buffer {
}
}
- [[nodiscard]] bool full() const override {
- return rptr_ == wptr_ && full_;
- }
+ [[nodiscard]] bool full() const override { return rptr_ == wptr_ && full_; }
- [[nodiscard]] bool empty() const override {
- return rptr_ == wptr_ && !full_;
- }
+ [[nodiscard]] bool empty() const override { return rptr_ == wptr_ && !full_; }
private:
void reset() {
@@ -163,9 +160,8 @@ class DynamicBuffer : public Buffer {
avail = end_ - wptr_;
} else if (std::cmp_less(end_ - data_.get(), max_size_)) {
size_t current_size = end_ - data_.get();
- size_t new_size = std::min(max_size_,
- current_size + std::max(need - avail,
- current_size));
+ size_t new_size = std::min(
+ max_size_, current_size + std::max(need - avail, current_size));
auto tmp = std::make_unique_for_overwrite<char[]>(new_size);
memcpy(tmp.get(), rptr_, wptr_ - rptr_);
end_ = tmp.get() + new_size;
@@ -185,12 +181,10 @@ class DynamicBuffer : public Buffer {
[[nodiscard]] bool full() const override {
return rptr_ == data_.get() && wptr_ == end_ &&
- std::cmp_equal(end_ - data_.get(), max_size_);
+ std::cmp_equal(end_ - data_.get(), max_size_);
}
- [[nodiscard]] bool empty() const override {
- return rptr_ == wptr_;
- }
+ [[nodiscard]] bool empty() const override { return rptr_ == wptr_; }
private:
void reset() {