Skip to content
Permalink
Browse files

Common/HttpRequest: std::move callback in constructor

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 8dc8cf8019339b15a00ac244ce36aa387a23bbb9
Showing with 2 additions and 2 deletions.
  1. +2 −2 Source/Core/Common/HttpRequest.cpp
@@ -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)))
{
}

@@ -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);

0 comments on commit 8dc8cf8

Please sign in to comment.
You can’t perform that action at this time.