Skip to content

Commit

Permalink
Common/HttpRequest: std::move callback in constructor
Browse files Browse the repository at this point in the history
std::function is allowed to heap allocate in order to hold any necessary
bound data in order to execute properly (e.g. lambdas with captures), so
this avoids unnecessary reallocating.
  • Loading branch information
lioncash committed May 27, 2019
1 parent 204af41 commit 8dc8cf8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Common/HttpRequest.cpp
Expand Up @@ -49,7 +49,7 @@ std::mutex HttpRequest::Impl::s_curl_was_inited_mutex;
bool HttpRequest::Impl::s_curl_was_inited = false;

HttpRequest::HttpRequest(std::chrono::milliseconds timeout_ms, ProgressCallback callback)
: m_impl(std::make_unique<Impl>(timeout_ms, callback))
: m_impl(std::make_unique<Impl>(timeout_ms, std::move(callback)))
{
}

Expand Down Expand Up @@ -107,7 +107,7 @@ int HttpRequest::Impl::CurlProgressCallback(Impl* impl, double dlnow, double dlt
}

HttpRequest::Impl::Impl(std::chrono::milliseconds timeout_ms, ProgressCallback callback)
: m_callback(callback)
: m_callback(std::move(callback))
{
{
std::lock_guard<std::mutex> lk(s_curl_was_inited_mutex);
Expand Down

0 comments on commit 8dc8cf8

Please sign in to comment.