use [[gnu::...]] attributes

This commit is contained in:
Max Kellermann
2023-03-06 15:57:36 +01:00
parent 3b9aab0684
commit 42f6a0441c
101 changed files with 167 additions and 234 deletions

View File

@@ -3,7 +3,6 @@
#include "BufferedSocket.hxx"
#include "net/SocketError.hxx"
#include "util/Compiler.h"
#include <stdexcept>
@@ -11,7 +10,7 @@ BufferedSocket::ssize_t
BufferedSocket::DirectRead(void *data, size_t length) noexcept
{
const auto nbytes = GetSocket().Read((char *)data, length);
if (gcc_likely(nbytes > 0))
if (nbytes > 0) [[likely]]
return nbytes;
if (nbytes == 0) {
@@ -86,7 +85,7 @@ BufferedSocket::OnSocketReady(unsigned flags) noexcept
{
assert(IsDefined());
if (gcc_unlikely(flags & (SocketEvent::ERROR|SocketEvent::HANGUP))) {
if (flags & (SocketEvent::ERROR|SocketEvent::HANGUP)) [[unlikely]] {
OnSocketClosed();
return;
}

View File

@@ -3,7 +3,6 @@
#include "FullyBufferedSocket.hxx"
#include "net/SocketError.hxx"
#include "util/Compiler.h"
#include <cassert>
@@ -13,7 +12,7 @@ FullyBufferedSocket::ssize_t
FullyBufferedSocket::DirectWrite(const void *data, size_t length) noexcept
{
const auto nbytes = GetSocket().Write((const char *)data, length);
if (gcc_unlikely(nbytes < 0)) {
if (nbytes < 0) [[unlikely]] {
const auto code = GetSocketError();
if (IsSocketErrorSendWouldBlock(code))
return 0;
@@ -43,7 +42,7 @@ FullyBufferedSocket::Flush() noexcept
}
auto nbytes = DirectWrite(data.data(), data.size());
if (gcc_unlikely(nbytes <= 0))
if (nbytes <= 0) [[unlikely]]
return nbytes == 0;
output.Consume(nbytes);