tempbuf.cpp 476 B

12345678910111213141516171819202122
  1. #include "tempbuf.h"
  2. namespace {
  3. static inline size_t Next(size_t size) noexcept {
  4. return size * 2;
  5. }
  6. } // namespace
  7. void TTempBufOutput::DoWrite(const void* data, size_t len) {
  8. if (Y_LIKELY(len <= Left())) {
  9. Append(data, len);
  10. } else {
  11. const size_t filled = Filled();
  12. TTempBuf buf(Next(filled + len));
  13. buf.Append(Data(), filled);
  14. buf.Append(data, len);
  15. static_cast<TTempBuf&>(*this) = buf;
  16. }
  17. }