This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push:
new 4b355d8 Eliminate unnecessary body copying in http::Response
constructor.
4b355d8 is described below
commit 4b355d84a3114c8fc8b9e20263321ff5b083e6da
Author: Benjamin Mahler <[email protected]>
AuthorDate: Fri Nov 8 16:11:20 2019 -0800
Eliminate unnecessary body copying in http::Response constructor.
This allows the caller to pass an rvalue reference to the body,
without it being copied.
Review: https://reviews.apache.org/r/71747
---
3rdparty/libprocess/include/process/http.hpp | 60 ++++++++++++++--------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/3rdparty/libprocess/include/process/http.hpp
b/3rdparty/libprocess/include/process/http.hpp
index a0065db..0013850 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -608,11 +608,11 @@ struct Response
}
explicit Response(
- const std::string& _body,
+ std::string _body,
uint16_t _code,
const std::string& contentType = "text/plain; charset=utf-8")
: type(BODY),
- body(_body),
+ body(std::move(_body)),
code(_code)
{
headers["Content-Length"] = stringify(body.size());
@@ -670,11 +670,11 @@ struct OK : Response
explicit OK(const char* body)
: Response(std::string(body), Status::OK) {}
- explicit OK(const std::string& body)
- : Response(body, Status::OK) {}
+ explicit OK(std::string body)
+ : Response(std::move(body), Status::OK) {}
- explicit OK(const std::string& body, const std::string& contentType)
- : Response(body, Status::OK, contentType) {}
+ explicit OK(std::string body, const std::string& contentType)
+ : Response(std::move(body), Status::OK, contentType) {}
OK(const JSON::Value& value, const Option<std::string>& jsonp = None());
@@ -687,8 +687,8 @@ struct Accepted : Response
Accepted()
: Response(Status::ACCEPTED) {}
- explicit Accepted(const std::string& body)
- : Response(body, Status::ACCEPTED) {}
+ explicit Accepted(std::string body)
+ : Response(std::move(body), Status::ACCEPTED) {}
};
@@ -707,8 +707,8 @@ struct BadRequest : Response
BadRequest()
: BadRequest("400 Bad Request.") {}
- explicit BadRequest(const std::string& body)
- : Response(body, Status::BAD_REQUEST) {}
+ explicit BadRequest(std::string body)
+ : Response(std::move(body), Status::BAD_REQUEST) {}
};
@@ -719,8 +719,8 @@ struct Unauthorized : Response
Unauthorized(
const std::vector<std::string>& challenges,
- const std::string& body)
- : Response(body, Status::UNAUTHORIZED)
+ std::string body)
+ : Response(std::move(body), Status::UNAUTHORIZED)
{
// TODO(arojas): Many HTTP client implementations do not support
// multiple challenges within a single 'WWW-Authenticate' header.
@@ -736,8 +736,8 @@ struct Forbidden : Response
Forbidden()
: Forbidden("403 Forbidden.") {}
- explicit Forbidden(const std::string& body)
- : Response(body, Status::FORBIDDEN) {}
+ explicit Forbidden(std::string body)
+ : Response(std::move(body), Status::FORBIDDEN) {}
};
@@ -746,8 +746,8 @@ struct NotFound : Response
NotFound()
: NotFound("404 Not Found.") {}
- explicit NotFound(const std::string& body)
- : Response(body, Status::NOT_FOUND) {}
+ explicit NotFound(std::string body)
+ : Response(std::move(body), Status::NOT_FOUND) {}
};
@@ -787,8 +787,8 @@ struct NotAcceptable : Response
NotAcceptable()
: NotAcceptable("406 Not Acceptable.") {}
- explicit NotAcceptable(const std::string& body)
- : Response(body, Status::NOT_ACCEPTABLE) {}
+ explicit NotAcceptable(std::string body)
+ : Response(std::move(body), Status::NOT_ACCEPTABLE) {}
};
@@ -797,8 +797,8 @@ struct Conflict : Response
Conflict()
: Conflict("409 Conflict.") {}
- explicit Conflict(const std::string& body)
- : Response(body, Status::CONFLICT) {}
+ explicit Conflict(std::string body)
+ : Response(std::move(body), Status::CONFLICT) {}
};
@@ -807,8 +807,8 @@ struct PreconditionFailed : Response
PreconditionFailed()
: PreconditionFailed("412 Precondition Failed.") {}
- explicit PreconditionFailed(const std::string& body)
- : Response(body, Status::PRECONDITION_FAILED) {}
+ explicit PreconditionFailed(std::string body)
+ : Response(std::move(body), Status::PRECONDITION_FAILED) {}
};
@@ -817,8 +817,8 @@ struct UnsupportedMediaType : Response
UnsupportedMediaType()
: UnsupportedMediaType("415 Unsupported Media Type.") {}
- explicit UnsupportedMediaType(const std::string& body)
- : Response(body, Status::UNSUPPORTED_MEDIA_TYPE) {}
+ explicit UnsupportedMediaType(std::string body)
+ : Response(std::move(body), Status::UNSUPPORTED_MEDIA_TYPE) {}
};
@@ -827,8 +827,8 @@ struct InternalServerError : Response
InternalServerError()
: InternalServerError("500 Internal Server Error.") {}
- explicit InternalServerError(const std::string& body)
- : Response(body, Status::INTERNAL_SERVER_ERROR) {}
+ explicit InternalServerError(std::string body)
+ : Response(std::move(body), Status::INTERNAL_SERVER_ERROR) {}
};
@@ -837,8 +837,8 @@ struct NotImplemented : Response
NotImplemented()
: NotImplemented("501 Not Implemented.") {}
- explicit NotImplemented(const std::string& body)
- : Response(body, Status::NOT_IMPLEMENTED) {}
+ explicit NotImplemented(std::string body)
+ : Response(std::move(body), Status::NOT_IMPLEMENTED) {}
};
@@ -847,8 +847,8 @@ struct ServiceUnavailable : Response
ServiceUnavailable()
: ServiceUnavailable("503 Service Unavailable.") {}
- explicit ServiceUnavailable(const std::string& body)
- : Response(body, Status::SERVICE_UNAVAILABLE) {}
+ explicit ServiceUnavailable(std::string body)
+ : Response(std::move(body), Status::SERVICE_UNAVAILABLE) {}
};