mirror of
https://github.com/NixOS/nix
synced 2025-06-28 01:11:15 +02:00
Rename and protect BufferedSink::write
The `write` name is ambiguous and could lead to some funny bugs like https://github.com/NixOS/nix/pull/8173#issuecomment-1500009480. So rename it to the more explicit `writeUnbuffered`. Besides, this method shouldn't be (and isn't) used outside of the class implementation, so mark it `protected`. This makes it more symetrical to `BufferedSource` which uses a `protected readUnbuffered` method.
This commit is contained in:
parent
9185639631
commit
214f1d6791
6 changed files with 14 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue