diff options
author | Mikhail Borisov <borisov.mikhail@gmail.com> | 2022-02-10 16:45:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:39 +0300 |
commit | a6a92afe03e02795227d2641b49819b687f088f8 (patch) | |
tree | f6984a1d27d5a7ec88a6fdd6e20cd5b7693b6ece /library/cpp/yson_pull/detail/byte_writer.h | |
parent | c6dc8b8bd530985bc4cce0137e9a5de32f1087cb (diff) | |
download | ydb-a6a92afe03e02795227d2641b49819b687f088f8.tar.gz |
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yson_pull/detail/byte_writer.h')
-rw-r--r-- | library/cpp/yson_pull/detail/byte_writer.h | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/library/cpp/yson_pull/detail/byte_writer.h b/library/cpp/yson_pull/detail/byte_writer.h index dc1d4b4b96..71ffe6230b 100644 --- a/library/cpp/yson_pull/detail/byte_writer.h +++ b/library/cpp/yson_pull/detail/byte_writer.h @@ -1,27 +1,27 @@ -#pragma once - -#include "macros.h" - +#pragma once + +#include "macros.h" + #include <library/cpp/yson_pull/output.h> - -#include <util/system/types.h> - -#include <cstddef> -#include <cstring> - + +#include <util/system/types.h> + +#include <cstddef> +#include <cstring> + namespace NYsonPull { namespace NDetail { template <class StreamCounter> class byte_writer { NYsonPull::NOutput::IStream& stream_; StreamCounter stream_counter_; - + public: byte_writer(NYsonPull::NOutput::IStream& stream) : stream_(stream) { } - + // const-ness added to prevent direct stream mutation const NYsonPull::NOutput::IStream& stream() { return stream_; @@ -29,11 +29,11 @@ namespace NYsonPull { const StreamCounter& counter() { return stream_counter_; } - + void flush_buffer() { stream_.flush_buffer(); } - + void advance(size_t bytes) { auto& buf = stream_.buffer(); stream_counter_.update( @@ -41,10 +41,10 @@ namespace NYsonPull { buf.pos() + bytes); buf.advance(bytes); } - + void write(ui8 c) { auto& buf = stream_.buffer(); - if (Y_LIKELY(!buf.is_full())) { + if (Y_LIKELY(!buf.is_full())) { *buf.pos() = c; advance(1); } else { @@ -53,11 +53,11 @@ namespace NYsonPull { stream_.flush_buffer({ptr, 1}); } } - + void write(const ui8* data, size_t size) { auto& buf = stream_.buffer(); auto free_buf = buf.available(); - if (Y_LIKELY(size < free_buf)) { + if (Y_LIKELY(size < free_buf)) { ::memcpy(buf.pos(), data, size); advance(size); } else { @@ -71,7 +71,7 @@ namespace NYsonPull { stream_.flush_buffer({reinterpret_cast<const char*>(data), size}); } - } + } }; - } + } } |