From 8dc8cf8019339b15a00ac244ce36aa387a23bbb9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 27 May 2019 09:25:05 -0400 Subject: [PATCH] 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. --- Source/Core/Common/HttpRequest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Common/HttpRequest.cpp b/Source/Core/Common/HttpRequest.cpp index 8098e315bd..f0da40cdea 100644 --- a/Source/Core/Common/HttpRequest.cpp +++ b/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(timeout_ms, callback)) + : m_impl(std::make_unique(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 lk(s_curl_was_inited_mutex);