diff --git a/src/event/FullyBufferedSocket.cxx b/src/event/FullyBufferedSocket.cxx index ca9db4dc0..b20457627 100644 --- a/src/event/FullyBufferedSocket.cxx +++ b/src/event/FullyBufferedSocket.cxx @@ -8,10 +8,10 @@ #include -FullyBufferedSocket::ssize_t -FullyBufferedSocket::DirectWrite(const void *data, size_t length) noexcept +inline FullyBufferedSocket::ssize_t +FullyBufferedSocket::DirectWrite(std::span src) noexcept { - const auto nbytes = GetSocket().Write((const char *)data, length); + const auto nbytes = GetSocket().Write((const char *)src.data(), src.size()); if (nbytes < 0) [[unlikely]] { const auto code = GetSocketError(); if (IsSocketErrorSendWouldBlock(code)) @@ -41,7 +41,7 @@ FullyBufferedSocket::Flush() noexcept return true; } - auto nbytes = DirectWrite(data.data(), data.size()); + auto nbytes = DirectWrite(data); if (nbytes <= 0) [[unlikely]] return nbytes == 0; diff --git a/src/event/FullyBufferedSocket.hxx b/src/event/FullyBufferedSocket.hxx index 586f37645..0955d3abc 100644 --- a/src/event/FullyBufferedSocket.hxx +++ b/src/event/FullyBufferedSocket.hxx @@ -1,13 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The Music Player Daemon Project -#ifndef MPD_FULLY_BUFFERED_SOCKET_HXX -#define MPD_FULLY_BUFFERED_SOCKET_HXX +#pragma once #include "BufferedSocket.hxx" #include "IdleEvent.hxx" #include "util/PeakBuffer.hxx" +#include + /** * A #BufferedSocket specialization that adds an output buffer. */ @@ -42,7 +43,7 @@ private: * socket isn't ready for writing, -1 on error (the socket has * been closed and probably destructed) */ - ssize_t DirectWrite(const void *data, size_t length) noexcept; + ssize_t DirectWrite(std::span src) noexcept; protected: /** @@ -62,5 +63,3 @@ protected: /* virtual methods from class BufferedSocket */ void OnSocketReady(unsigned flags) noexcept override; }; - -#endif