diff options
author | shakurov <shakurov@yandex-team.ru> | 2022-02-10 16:49:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:23 +0300 |
commit | 296627beeba9eb1fbc3cc1ff3dbae3ff192fb2a8 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/binsaver/buffered_io.cpp | |
parent | 6750fac04a33847862ab7bfb19145f6f91207be6 (diff) | |
download | ydb-296627beeba9eb1fbc3cc1ff3dbae3ff192fb2a8.tar.gz |
Restoring authorship annotation for <shakurov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/binsaver/buffered_io.cpp')
-rw-r--r-- | library/cpp/binsaver/buffered_io.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/library/cpp/binsaver/buffered_io.cpp b/library/cpp/binsaver/buffered_io.cpp index da9cef5da4..dd88b04bc5 100644 --- a/library/cpp/binsaver/buffered_io.cpp +++ b/library/cpp/binsaver/buffered_io.cpp @@ -3,37 +3,37 @@ i64 IBinaryStream::LongWrite(const void* userBuffer, i64 size) { Y_VERIFY(size >= 0, "IBinaryStream::Write() called with a negative buffer size."); - i64 leftToWrite = size; - while (leftToWrite != 0) { - int writeSz = static_cast<int>(Min<i64>(leftToWrite, std::numeric_limits<int>::max())); - int written = WriteImpl(userBuffer, writeSz); + i64 leftToWrite = size; + while (leftToWrite != 0) { + int writeSz = static_cast<int>(Min<i64>(leftToWrite, std::numeric_limits<int>::max())); + int written = WriteImpl(userBuffer, writeSz); Y_ASSERT(written <= writeSz); - leftToWrite -= written; - // Assumption: if WriteImpl(buf, writeSz) returns < writeSz, the stream is - // full and there's no sense in continuing. - if (written < writeSz) - break; - } + leftToWrite -= written; + // Assumption: if WriteImpl(buf, writeSz) returns < writeSz, the stream is + // full and there's no sense in continuing. + if (written < writeSz) + break; + } Y_ASSERT(size >= leftToWrite); - return size - leftToWrite; -} - + return size - leftToWrite; +} + i64 IBinaryStream::LongRead(void* userBuffer, i64 size) { Y_VERIFY(size >= 0, "IBinaryStream::Read() called with a negative buffer size."); - - i64 leftToRead = size; - while (leftToRead != 0) { - int readSz = static_cast<int>(Min<i64>(leftToRead, std::numeric_limits<int>::max())); - int read = ReadImpl(userBuffer, readSz); + + i64 leftToRead = size; + while (leftToRead != 0) { + int readSz = static_cast<int>(Min<i64>(leftToRead, std::numeric_limits<int>::max())); + int read = ReadImpl(userBuffer, readSz); Y_ASSERT(read <= readSz); - leftToRead -= read; - // Assumption: if ReadImpl(buf, readSz) returns < readSz, the stream is - // full and there's no sense in continuing. - if (read < readSz) { - memset(static_cast<char*>(userBuffer) + (size - leftToRead), 0, leftToRead); - break; - } - } + leftToRead -= read; + // Assumption: if ReadImpl(buf, readSz) returns < readSz, the stream is + // full and there's no sense in continuing. + if (read < readSz) { + memset(static_cast<char*>(userBuffer) + (size - leftToRead), 0, leftToRead); + break; + } + } Y_ASSERT(size >= leftToRead); - return size - leftToRead; -} + return size - leftToRead; +} |