aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/tempbuf.cpp
blob: 4fd8fc8112de0295aea35d7b0bd10032654f8081 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#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;
    }
}