1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 15:24:30 +01:00

Using std::move(), correct clear strings, better use '= default;', modernize make_* and replace heavy strlen

This commit is contained in:
germanaizek
2022-04-25 16:37:32 +03:00
committed by Hielke Morsink
parent 0045aed7f9
commit 958bfbc08a
28 changed files with 59 additions and 67 deletions

View File

@@ -257,6 +257,14 @@ private:
public:
TcpSocket() noexcept = default;
explicit TcpSocket(SOCKET socket, std::string hostName, std::string ipAddress) noexcept
: _status(SocketStatus::Connected)
, _socket(socket)
, _ipAddress(std::move(ipAddress))
, _hostName(std::move(hostName))
{
}
~TcpSocket() override
{
if (_connectFuture.valid())
@@ -388,11 +396,11 @@ public:
if (rc == 0)
{
tcpSocket = std::unique_ptr<ITcpSocket>(new TcpSocket(socket, hostName, ipAddress));
tcpSocket = std::make_unique<TcpSocket>(socket, hostName, ipAddress);
}
else
{
tcpSocket = std::unique_ptr<ITcpSocket>(new TcpSocket(socket, "", ipAddress));
tcpSocket = std::make_unique<TcpSocket>(socket, "", ipAddress);
}
}
}
@@ -622,14 +630,6 @@ public:
}
private:
explicit TcpSocket(SOCKET socket, std::string hostName, std::string ipAddress) noexcept
: _status(SocketStatus::Connected)
, _socket(socket)
, _ipAddress(std::move(ipAddress))
, _hostName(std::move(hostName))
{
}
void CloseSocket()
{
if (_socket != INVALID_SOCKET)