forked from lix-project/lix
Merge pull request #8176 from tweag/rename-confusing-write-method
Rename and protect `BufferedSink::write`
This commit is contained in:
commit
33fc09c2a5
|
@ -23,7 +23,7 @@ struct ChunkedCompressionSink : CompressionSink
|
|||
{
|
||||
uint8_t outbuf[32 * 1024];
|
||||
|
||||
void write(std::string_view data) override
|
||||
void writeUnbuffered(std::string_view data) override
|
||||
{
|
||||
const size_t CHUNK_SIZE = sizeof(outbuf) << 2;
|
||||
while (!data.empty()) {
|
||||
|
@ -103,7 +103,7 @@ struct ArchiveCompressionSink : CompressionSink
|
|||
throw Error(reason, archive_error_string(this->archive));
|
||||
}
|
||||
|
||||
void write(std::string_view data) override
|
||||
void writeUnbuffered(std::string_view data) override
|
||||
{
|
||||
ssize_t result = archive_write_data(archive, data.data(), data.length());
|
||||
if (result <= 0) check(result);
|
||||
|
@ -136,7 +136,7 @@ struct NoneSink : CompressionSink
|
|||
warn("requested compression level '%d' not supported by compression method 'none'", level);
|
||||
}
|
||||
void finish() override { flush(); }
|
||||
void write(std::string_view data) override { nextSink(data); }
|
||||
void writeUnbuffered(std::string_view data) override { nextSink(data); }
|
||||
};
|
||||
|
||||
struct BrotliDecompressionSink : ChunkedCompressionSink
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace nix {
|
|||
struct CompressionSink : BufferedSink, FinishSink
|
||||
{
|
||||
using BufferedSink::operator ();
|
||||
using BufferedSink::write;
|
||||
using BufferedSink::writeUnbuffered;
|
||||
using FinishSink::finish;
|
||||
};
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ HashSink::~HashSink()
|
|||
delete ctx;
|
||||
}
|
||||
|
||||
void HashSink::write(std::string_view data)
|
||||
void HashSink::writeUnbuffered(std::string_view data)
|
||||
{
|
||||
bytes += data.size();
|
||||
update(ht, *ctx, data);
|
||||
|
|
|
@ -197,7 +197,7 @@ public:
|
|||
HashSink(HashType ht);
|
||||
HashSink(const HashSink & h);
|
||||
~HashSink();
|
||||
void write(std::string_view data) override;
|
||||
void writeUnbuffered(std::string_view data) override;
|
||||
HashResult finish() override;
|
||||
HashResult currentHash();
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ void BufferedSink::operator () (std::string_view data)
|
|||
buffer size. */
|
||||
if (bufPos + data.size() >= bufSize) {
|
||||
flush();
|
||||
write(data);
|
||||
writeUnbuffered(data);
|
||||
break;
|
||||
}
|
||||
/* Otherwise, copy the bytes to the buffer. Flush the buffer
|
||||
|
@ -38,7 +38,7 @@ void BufferedSink::flush()
|
|||
if (bufPos == 0) return;
|
||||
size_t n = bufPos;
|
||||
bufPos = 0; // don't trigger the assert() in ~BufferedSink()
|
||||
write({buffer.get(), n});
|
||||
writeUnbuffered({buffer.get(), n});
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ FdSink::~FdSink()
|
|||
}
|
||||
|
||||
|
||||
void FdSink::write(std::string_view data)
|
||||
void FdSink::writeUnbuffered(std::string_view data)
|
||||
{
|
||||
written += data.size();
|
||||
try {
|
||||
|
|
|
@ -53,7 +53,9 @@ struct BufferedSink : virtual Sink
|
|||
|
||||
void flush();
|
||||
|
||||
virtual void write(std::string_view data) = 0;
|
||||
protected:
|
||||
|
||||
virtual void writeUnbuffered(std::string_view data) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -133,7 +135,7 @@ struct FdSink : BufferedSink
|
|||
|
||||
~FdSink();
|
||||
|
||||
void write(std::string_view data) override;
|
||||
void writeUnbuffered(std::string_view data) override;
|
||||
|
||||
bool good() override;
|
||||
|
||||
|
@ -520,7 +522,7 @@ struct FramedSink : nix::BufferedSink
|
|||
}
|
||||
}
|
||||
|
||||
void write(std::string_view data) override
|
||||
void writeUnbuffered(std::string_view data) override
|
||||
{
|
||||
/* Don't send more data if the remote has
|
||||
encountered an error. */
|
||||
|
|
Loading…
Reference in a new issue