aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/tempbuf.cpp
blob: 3529953687bd0b8c69316eb56953ea213e17f319 (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;
    }
}