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.
This commit is contained in:
parent
204af41e73
commit
8dc8cf8019
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue