Pre-allocate up-front whenever possible

This commit is contained in:
Daniel J. Hofmann
2016-06-08 11:28:32 +02:00
parent 1c140a112a
commit 033dc0a72d
6 changed files with 16 additions and 2 deletions
+3 -1
View File
@@ -105,9 +105,11 @@ void RequestHandler::HandleRequest(const http::request &current_request, http::r
else
{
BOOST_ASSERT(result.is<std::string>());
current_reply.content.resize(current_reply.content.size() +
result.get<std::string>().size());
std::copy(result.get<std::string>().cbegin(),
result.get<std::string>().cend(),
std::back_inserter(current_reply.content));
current_reply.content.end());
current_reply.headers.emplace_back("Content-Type", "application/x-protobuf");
}