*: add "noexcept" to many, many function prototypes
This eliminates some overhead, because the compiler doesn't need to consider these functions throwing.
This commit is contained in:
@@ -50,7 +50,7 @@ AllocatedSocketAddress::operator=(SocketAddress src)
|
||||
}
|
||||
|
||||
void
|
||||
AllocatedSocketAddress::SetSize(size_type new_size)
|
||||
AllocatedSocketAddress::SetSize(size_type new_size) noexcept
|
||||
{
|
||||
if (size == new_size)
|
||||
return;
|
||||
@@ -63,7 +63,7 @@ AllocatedSocketAddress::SetSize(size_type new_size)
|
||||
#ifdef HAVE_UN
|
||||
|
||||
void
|
||||
AllocatedSocketAddress::SetLocal(const char *path)
|
||||
AllocatedSocketAddress::SetLocal(const char *path) noexcept
|
||||
{
|
||||
const bool is_abstract = *path == '@';
|
||||
|
||||
|
@@ -140,11 +140,11 @@ public:
|
||||
* begins with a '@', then the rest specifies an "abstract" local
|
||||
* address.
|
||||
*/
|
||||
void SetLocal(const char *path);
|
||||
void SetLocal(const char *path) noexcept;
|
||||
#endif
|
||||
|
||||
private:
|
||||
void SetSize(size_type new_size);
|
||||
void SetSize(size_type new_size) noexcept;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -32,7 +32,7 @@
|
||||
#include <string.h>
|
||||
|
||||
bool
|
||||
SocketAddress::operator==(SocketAddress other) const
|
||||
SocketAddress::operator==(SocketAddress other) const noexcept
|
||||
{
|
||||
return size == other.size && memcmp(address, other.address, size) == 0;
|
||||
}
|
||||
|
@@ -93,9 +93,9 @@ public:
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
bool operator==(const SocketAddress other) const;
|
||||
bool operator==(const SocketAddress other) const noexcept;
|
||||
|
||||
bool operator!=(const SocketAddress other) const {
|
||||
bool operator!=(const SocketAddress other) const noexcept {
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
SocketErrorMessage::SocketErrorMessage(socket_error_t code)
|
||||
SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
wchar_t buffer[ARRAY_SIZE(msg)];
|
||||
@@ -56,7 +56,7 @@ SocketErrorMessage::SocketErrorMessage(socket_error_t code)
|
||||
|
||||
#else
|
||||
|
||||
SocketErrorMessage::SocketErrorMessage(socket_error_t code)
|
||||
SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept
|
||||
:msg(strerror(code)) {}
|
||||
|
||||
#endif
|
||||
|
@@ -33,7 +33,7 @@ typedef int socket_error_t;
|
||||
|
||||
gcc_pure
|
||||
static inline socket_error_t
|
||||
GetSocketError()
|
||||
GetSocketError() noexcept
|
||||
{
|
||||
#ifdef WIN32
|
||||
return WSAGetLastError();
|
||||
@@ -44,7 +44,7 @@ GetSocketError()
|
||||
|
||||
gcc_const
|
||||
static inline bool
|
||||
IsSocketErrorAgain(socket_error_t code)
|
||||
IsSocketErrorAgain(socket_error_t code) noexcept
|
||||
{
|
||||
#ifdef WIN32
|
||||
return code == WSAEINPROGRESS;
|
||||
@@ -55,7 +55,7 @@ IsSocketErrorAgain(socket_error_t code)
|
||||
|
||||
gcc_const
|
||||
static inline bool
|
||||
IsSocketErrorInterruped(socket_error_t code)
|
||||
IsSocketErrorInterruped(socket_error_t code) noexcept
|
||||
{
|
||||
#ifdef WIN32
|
||||
return code == WSAEINTR;
|
||||
@@ -66,7 +66,7 @@ IsSocketErrorInterruped(socket_error_t code)
|
||||
|
||||
gcc_const
|
||||
static inline bool
|
||||
IsSocketErrorClosed(socket_error_t code)
|
||||
IsSocketErrorClosed(socket_error_t code) noexcept
|
||||
{
|
||||
#ifdef WIN32
|
||||
return code == WSAECONNRESET;
|
||||
@@ -88,11 +88,7 @@ class SocketErrorMessage {
|
||||
#endif
|
||||
|
||||
public:
|
||||
#ifdef WIN32
|
||||
explicit SocketErrorMessage(socket_error_t code=GetSocketError());
|
||||
#else
|
||||
explicit SocketErrorMessage(socket_error_t code=GetSocketError());
|
||||
#endif
|
||||
explicit SocketErrorMessage(socket_error_t code=GetSocketError()) noexcept;
|
||||
|
||||
operator const char *() const {
|
||||
return msg;
|
||||
@@ -101,7 +97,7 @@ public:
|
||||
|
||||
gcc_const
|
||||
static inline std::system_error
|
||||
MakeSocketError(socket_error_t code, const char *msg)
|
||||
MakeSocketError(socket_error_t code, const char *msg) noexcept
|
||||
{
|
||||
#ifdef WIN32
|
||||
return MakeLastError(code, msg);
|
||||
@@ -112,7 +108,7 @@ MakeSocketError(socket_error_t code, const char *msg)
|
||||
|
||||
gcc_pure
|
||||
static inline std::system_error
|
||||
MakeSocketError(const char *msg)
|
||||
MakeSocketError(const char *msg) noexcept
|
||||
{
|
||||
return MakeSocketError(GetSocketError(), msg);
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include <string.h>
|
||||
|
||||
StaticSocketAddress &
|
||||
StaticSocketAddress::operator=(SocketAddress other)
|
||||
StaticSocketAddress::operator=(SocketAddress other) noexcept
|
||||
{
|
||||
size = std::min(other.GetSize(), GetCapacity());
|
||||
memcpy(&address, other.GetAddress(), size);
|
||||
|
@@ -49,7 +49,7 @@ private:
|
||||
public:
|
||||
StaticSocketAddress() = default;
|
||||
|
||||
StaticSocketAddress &operator=(SocketAddress other);
|
||||
StaticSocketAddress &operator=(SocketAddress other) noexcept;
|
||||
|
||||
operator SocketAddress() const {
|
||||
return SocketAddress(reinterpret_cast<const struct sockaddr *>(&address),
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2015 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright (C) 2011-2017 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -53,7 +53,7 @@
|
||||
#ifdef HAVE_UN
|
||||
|
||||
static std::string
|
||||
LocalAddressToString(const struct sockaddr_un &s_un, size_t size)
|
||||
LocalAddressToString(const struct sockaddr_un &s_un, size_t size) noexcept
|
||||
{
|
||||
const size_t prefix_size = (size_t)
|
||||
((struct sockaddr_un *)nullptr)->sun_path;
|
||||
@@ -83,7 +83,7 @@ LocalAddressToString(const struct sockaddr_un &s_un, size_t size)
|
||||
|
||||
gcc_pure
|
||||
static bool
|
||||
IsV4Mapped(SocketAddress address)
|
||||
IsV4Mapped(SocketAddress address) noexcept
|
||||
{
|
||||
if (address.GetFamily() != AF_INET6)
|
||||
return false;
|
||||
@@ -96,7 +96,7 @@ IsV4Mapped(SocketAddress address)
|
||||
* Convert "::ffff:127.0.0.1" to "127.0.0.1".
|
||||
*/
|
||||
static SocketAddress
|
||||
UnmapV4(SocketAddress src, struct sockaddr_in &buffer)
|
||||
UnmapV4(SocketAddress src, struct sockaddr_in &buffer) noexcept
|
||||
{
|
||||
assert(IsV4Mapped(src));
|
||||
|
||||
@@ -113,7 +113,7 @@ UnmapV4(SocketAddress src, struct sockaddr_in &buffer)
|
||||
#endif
|
||||
|
||||
std::string
|
||||
ToString(SocketAddress address)
|
||||
ToString(SocketAddress address) noexcept
|
||||
{
|
||||
#ifdef HAVE_UN
|
||||
if (address.GetFamily() == AF_UNIX)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2015 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright (C) 2011-2017 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -43,6 +43,6 @@ class SocketAddress;
|
||||
*/
|
||||
gcc_pure
|
||||
std::string
|
||||
ToString(SocketAddress address);
|
||||
ToString(SocketAddress address) noexcept;
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user