aboutsummaryrefslogblamecommitdiffstats
path: root/util/stream/tempbuf.cpp
blob: 801a1fabb056cf10f50012d316ef252fbf61fe27 (plain) (tree)
1
2
3
4
5
6
7
8
9

                    
                                                     


                        
                                                            
                                  










                                            
#include "tempbuf.h"

namespace {
    static inline size_t Next(size_t size) noexcept {
        return size * 2;
    }
}

void TTempBufOutput::DoWrite(const void* data, size_t len) {
    if (Y_LIKELY(len <= Left())) {
        Append(data, len);
    } else {
        const size_t filled = Filled();

        TTempBuf buf(Next(filled + len));

        buf.Append(Data(), filled);
        buf.Append(data, len);

        static_cast<TTempBuf&>(*this) = buf;
    }
}