util/*FifoBuffer: migrate from WritableBuffer to std::span

This commit is contained in:
Max Kellermann
2022-05-10 17:26:41 +02:00
committed by Max Kellermann
parent 570755f05a
commit bb7be9a4cd
23 changed files with 114 additions and 129 deletions

View File

@@ -54,7 +54,7 @@ BufferedSocket::ReadToBuffer() noexcept
const auto buffer = input.Write();
assert(!buffer.empty());
const auto nbytes = DirectRead(buffer.data, buffer.size);
const auto nbytes = DirectRead(buffer.data(), buffer.size());
if (nbytes > 0)
input.Append(nbytes);
@@ -73,7 +73,7 @@ BufferedSocket::ResumeInput() noexcept
return true;
}
const auto result = OnSocketInput(buffer.data, buffer.size);
const auto result = OnSocketInput(buffer.data(), buffer.size());
switch (result) {
case InputResult::MORE:
if (input.IsFull()) {

View File

@@ -58,7 +58,7 @@ FullyBufferedSocket::Flush() noexcept
return true;
}
auto nbytes = DirectWrite(data.data, data.size);
auto nbytes = DirectWrite(data.data(), data.size());
if (gcc_unlikely(nbytes <= 0))
return nbytes == 0;
@@ -82,7 +82,7 @@ FullyBufferedSocket::Write(const void *data, size_t length) noexcept
const bool was_empty = output.empty();
if (!output.Append(data, length)) {
if (!output.Append({(const std::byte *)data, length})) {
OnSocketError(std::make_exception_ptr(std::runtime_error("Output buffer is full")));
return false;
}