Skip to content

Commit

Permalink
Avoid double-call to copy constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastiano Merlino committed Sep 19, 2016
1 parent 4c18ce7 commit b044530
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion examples/benchmark.cpp
Expand Up @@ -44,7 +44,7 @@ const http_response hello_world_resource::render(const http_request& req)
{
//it is possible to send a response initializing an http_string_response
//that reads the content to send in response from a string.
return http_response(http_response_builder(PAGE, 200).string_response());
return http_response_builder(PAGE, 200).string_response();
}

int main()
Expand Down
4 changes: 2 additions & 2 deletions examples/comet.cpp
Expand Up @@ -31,15 +31,15 @@ class comet_send_resource : public http_resource {
public:
const http_response render(const http_request& req)
{
return http_response(http_response_builder("Hi", 200).long_polling_send_response(topics_array[0]));
return http_response_builder("Hi", 200).long_polling_send_response(topics_array[0]);
}
};

class comet_listen_resource : public http_resource {
public:
const http_response render(const http_request& req)
{
return http_response(http_response_builder("OK", 200).long_polling_receive_response(topics));
return http_response_builder("OK", 200).long_polling_receive_response(topics);
}
};

Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world.cpp
Expand Up @@ -42,7 +42,7 @@ const http_response hello_world_resource::render(const http_request& req)

//it is possible to send a response initializing an http_string_response
//that reads the content to send in response from a string.
return http_response(http_response_builder("Hello World!!!", 200).string_response());
return http_response_builder("Hello World!!!", 200).string_response();
}

int main()
Expand Down
6 changes: 3 additions & 3 deletions src/webserver.cpp
Expand Up @@ -615,7 +615,7 @@ const http_response webserver::not_found_page(details::modded_request* mr) const
}
else
{
return http_response(http_response_builder(NOT_FOUND_ERROR, http_utils::http_not_found).string_response());
return http_response_builder(NOT_FOUND_ERROR, http_utils::http_not_found).string_response();
}
}

Expand All @@ -627,7 +627,7 @@ const http_response webserver::method_not_allowed_page(details::modded_request*
}
else
{
return http_response(http_response_builder(METHOD_ERROR, http_utils::http_method_not_allowed).string_response());
return http_response_builder(METHOD_ERROR, http_utils::http_method_not_allowed).string_response();
}
}

Expand All @@ -636,7 +636,7 @@ const http_response webserver::internal_error_page(details::modded_request* mr,
if(internal_error_resource != 0x0 && !force_our)
return internal_error_resource(*mr->dhr);
else
return http_response(http_response_builder(GENERIC_ERROR, http_utils::http_internal_server_error).string_response());
return http_response_builder(GENERIC_ERROR, http_utils::http_internal_server_error).string_response();
}

int webserver::bodyless_requests_answer(
Expand Down
24 changes: 12 additions & 12 deletions test/integ/basic.cpp
Expand Up @@ -50,11 +50,11 @@ class simple_resource : public http_resource
public:
const http_response render_GET(const http_request& req)
{
return http_response(http_response_builder("OK", 200, "text/plain").string_response());
return http_response_builder("OK", 200, "text/plain").string_response();
}
const http_response render_POST(const http_request& req)
{
return http_response(http_response_builder(req.get_arg("arg1")+req.get_arg("arg2"), 200, "text/plain").string_response());
return http_response_builder(req.get_arg("arg1")+req.get_arg("arg2"), 200, "text/plain").string_response();
}
};

Expand All @@ -63,7 +63,7 @@ class long_content_resource : public http_resource
public:
const http_response render_GET(const http_request& req)
{
return http_response(http_response_builder(lorem_ipsum, 200, "text/plain").string_response());
return http_response_builder(lorem_ipsum, 200, "text/plain").string_response();
}
};

Expand All @@ -74,7 +74,7 @@ class header_test_resource : public http_resource
{
http_response_builder hrb("OK", 200, "text/plain");
hrb.with_header("KEY", "VALUE");
return http_response(hrb.string_response());
return http_response(hrb.string_response();
}
};

Expand All @@ -83,23 +83,23 @@ class complete_test_resource : public http_resource
public:
const http_response render_GET(const http_request& req)
{
return http_response(http_response_builder("OK", 200, "text/plain").string_response());
return http_response_builder("OK", 200, "text/plain").string_response();
}
const http_response render_POST(const http_request& req)
{
return http_response(http_response_builder("OK", 200, "text/plain").string_response());
return http_response_builder("OK", 200, "text/plain").string_response();
}
const http_response render_PUT(const http_request& req)
{
return http_response(http_response_builder("OK", 200, "text/plain").string_response());
return http_response_builder("OK", 200, "text/plain").string_response();
}
const http_response render_DELETE(const http_request& req)
{
return http_response(http_response_builder("OK", 200, "text/plain").string_response());
return http_response_builder("OK", 200, "text/plain").string_response();
}
const http_response render_CONNECT(const http_request& req)
{
return http_response(http_response_builder("OK", 200, "text/plain").string_response());
return http_response_builder("OK", 200, "text/plain").string_response();
}
};

Expand All @@ -108,7 +108,7 @@ class only_render_resource : public http_resource
public:
const http_response render(const http_request& req)
{
return http_response(http_response_builder("OK", 200, "text/plain").string_response());
return http_response_builder("OK", 200, "text/plain").string_response();
}
};

Expand All @@ -117,7 +117,7 @@ class ok_resource : public http_resource
public:
const http_response render_GET(const http_request& req)
{
return http_response(http_response_builder("OK", 200, "text/plain").string_response());
return http_response_builder("OK", 200, "text/plain").string_response();
}
};

Expand All @@ -126,7 +126,7 @@ class nok_resource : public http_resource
public:
const http_response render_GET(const http_request& req)
{
return http_response(http_response_builder("NOK", 200, "text/plain").string_response());
return http_response_builder("NOK", 200, "text/plain").string_response();
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/integ/threaded.cpp
Expand Up @@ -32,7 +32,7 @@ class ok_resource : public http_resource
public:
const http_response render_GET(const http_request& req)
{
return http_response(http_response_builder("OK", 200, "text/plain").string_response());
return http_response_builder("OK", 200, "text/plain").string_response();
}
};

Expand Down

0 comments on commit b044530

Please sign in to comment.