mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +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
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue