diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/stream/str.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/stream/str.cpp')
-rw-r--r-- | util/stream/str.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/util/stream/str.cpp b/util/stream/str.cpp index 3be3435db5..13f0e8ef28 100644 --- a/util/stream/str.cpp +++ b/util/stream/str.cpp @@ -1,9 +1,9 @@ -#include "str.h" - +#include "str.h" + static constexpr size_t MIN_BUFFER_GROW_SIZE = 16; TStringInput::~TStringInput() = default; - + size_t TStringInput::DoNext(const void** ptr, size_t len) { len = Min(len, S_->size() - Pos_); *ptr = S_->data() + Pos_; @@ -17,28 +17,28 @@ void TStringInput::DoUndo(size_t len) { } TStringOutput::~TStringOutput() = default; - + size_t TStringOutput::DoNext(void** ptr) { - if (S_->size() == S_->capacity()) { - S_->reserve(FastClp2(S_->capacity() + MIN_BUFFER_GROW_SIZE)); + if (S_->size() == S_->capacity()) { + S_->reserve(FastClp2(S_->capacity() + MIN_BUFFER_GROW_SIZE)); } - size_t previousSize = S_->size(); - ResizeUninitialized(*S_, S_->capacity()); - *ptr = S_->begin() + previousSize; - return S_->size() - previousSize; + size_t previousSize = S_->size(); + ResizeUninitialized(*S_, S_->capacity()); + *ptr = S_->begin() + previousSize; + return S_->size() - previousSize; } void TStringOutput::DoUndo(size_t len) { - Y_VERIFY(len <= S_->size(), "trying to undo more bytes than actually written"); - S_->resize(S_->size() - len); + Y_VERIFY(len <= S_->size(), "trying to undo more bytes than actually written"); + S_->resize(S_->size() - len); +} + +void TStringOutput::DoWrite(const void* buf, size_t len) { + S_->append((const char*)buf, len); } -void TStringOutput::DoWrite(const void* buf, size_t len) { - S_->append((const char*)buf, len); -} - void TStringOutput::DoWriteC(char c) { - S_->push_back(c); + S_->push_back(c); } TStringStream::~TStringStream() = default; |