Skip to content

Commit

Permalink
Remove redundant std::move's
Browse files Browse the repository at this point in the history
  • Loading branch information
kuznetsss committed Oct 21, 2024
1 parent 0b2abe6 commit 633707a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/web/ng/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "util/config/Config.hpp"
#include "util/log/Logger.hpp"
#include "web/ng/Connection.hpp"
#include "web/ng/Error.hpp"
#include "web/ng/MessageHandler.hpp"
#include "web/ng/impl/HttpConnection.hpp"
#include "web/ng/impl/ServerSslContext.hpp"
Expand Down Expand Up @@ -87,7 +86,7 @@ makeAcceptor(boost::asio::io_context& context, boost::asio::ip::tcp::endpoint co
} catch (boost::system::system_error const& error) {
return std::unexpected{fmt::format("Error creating TCP acceptor: {}", error.what())};
}

Check warning on line 88 in src/web/ng/Server.cpp

View check run for this annotation

Codecov / codecov/patch

src/web/ng/Server.cpp#L87-L88

Added lines #L87 - L88 were not covered by tests
return std::move(acceptor);
return acceptor;
}

std::expected<std::string, boost::system::system_error>
Expand Down
4 changes: 2 additions & 2 deletions src/web/ng/impl/HttpConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class HttpConnection : public UpgradableConnection {
if (request_.has_value()) {
Request result{std::move(request_).value()};
request_.reset();
return std::move(result);
return result;
}
auto expectedRequest = fetch(yield, timeout);
if (expectedRequest.has_value())
Expand Down Expand Up @@ -208,7 +208,7 @@ class HttpConnection : public UpgradableConnection {
boost::beast::http::async_read(stream_, buffer_, request, yield[error]);
if (error)
return std::unexpected{error};
return std::move(request);
return request;
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/web/ng/impl/WsConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ make_PlainWsConnection(
auto maybeError = connection->performHandshake(yield);
if (maybeError.has_value())
return std::unexpected{maybeError.value()};
return std::move(connection);
return connection;
}

std::expected<std::unique_ptr<SslWsConnection>, Error>
Expand All @@ -71,7 +71,7 @@ make_SslWsConnection(
auto maybeError = connection->performHandshake(yield);
if (maybeError.has_value())
return std::unexpected{maybeError.value()};
return std::move(connection);
return connection;
}

Check warning on line 75 in src/web/ng/impl/WsConnection.cpp

View check run for this annotation

Codecov / codecov/patch

src/web/ng/impl/WsConnection.cpp#L74-L75

Added lines #L74 - L75 were not covered by tests

} // namespace web::ng::impl
2 changes: 1 addition & 1 deletion src/web/ng/impl/WsConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class WsConnection : public Connection {
[this, &response](auto&& yield) { stream_.async_write(response.asConstBuffer(), yield); }, yield, timeout
);
if (error)
return std::move(error);
return error;
return std::nullopt;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/common/util/TestHttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ HttpAsyncClient::receive(boost::asio::yield_context yield, std::chrono::steady_c
http::async_read(stream_, buffer_, response, yield[error]);
if (error)
return std::unexpected{error};
return std::move(response);
return response;
}

void
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/web/ng/impl/ConnectionHandlerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,13 @@ TEST_F(ConnectionHandlerSequentialProcessingTest, Stop)
}

struct ConnectionHandlerParallelProcessingTest : ConnectionHandlerTest {
static size_t const maxParallelRequests = 3;
static size_t constexpr maxParallelRequests = 3;

ConnectionHandlerParallelProcessingTest()
: ConnectionHandlerTest(ConnectionHandler::ProcessingPolicy::Parallel, maxParallelRequests)
: ConnectionHandlerTest(
ConnectionHandler::ProcessingPolicy::Parallel,
ConnectionHandlerParallelProcessingTest::maxParallelRequests
)
{
}

Expand Down

0 comments on commit 633707a

Please sign in to comment.