Commit 16a69ee1 authored by hyperxor's avatar hyperxor

Fix several unnecessary copies of objects

parent 166d82dc
......@@ -282,7 +282,7 @@ public:
std::vector<TypedParam> splat() const;
private:
explicit Request(const Http::Request &request,
explicit Request(Http::Request request,
std::vector<TypedParam> &&params,
std::vector<TypedParam> &&splats);
......
......@@ -924,15 +924,15 @@ void Handler::onInput(const char *buffer, size_t len,
}
auto state = parser.parse();
auto& request = parser.request;
if (state == Private::State::Done) {
ResponseWriter response(transport(), parser.request, this, peer);
ResponseWriter response(transport(), request, this, peer);
#ifdef LIBSTDCPP_SMARTPTR_LOCK_FIXME
parser.request.associatePeer(peer);
request.associatePeer(peer);
#endif
auto request = parser.request;
request.copyAddress(peer->address());
auto connection = request.headers().tryGet<Header::Connection>();
......
......@@ -12,9 +12,9 @@
namespace Pistache {
namespace Rest {
Request::Request(const Http::Request &request, std::vector<TypedParam> &&params,
Request::Request(Http::Request request, std::vector<TypedParam> &&params,
std::vector<TypedParam> &&splats)
: Http::Request(request), params_(std::move(params)),
: Http::Request(std::move(request)), params_(std::move(params)),
splats_(std::move(splats)) {}
bool Request::hasParam(const std::string &name) const {
......@@ -303,8 +303,7 @@ RouterHandler::RouterHandler(std::shared_ptr<Rest::Router> router)
void RouterHandler::onRequest(const Http::Request &req,
Http::ResponseWriter response) {
auto resp = response.clone();
router->route(req, std::move(resp));
router->route(req, std::move(response));
}
} // namespace Private
......@@ -422,7 +421,7 @@ Route::Status Router::route(const Http::Request &http_req,
if (route != nullptr) {
auto params = std::get<1>(result);
auto splats = std::get<2>(result);
route->invokeHandler(Request(req, std::move(params), std::move(splats)),
route->invokeHandler(Request(std::move(req), std::move(params), std::move(splats)),
std::move(resp));
return Route::Status::Match;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment