From 0891cd4878a53bfcb59d08f8740f5cc4a2c91935 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 26 Aug 2019 01:21:36 +0800 Subject: [PATCH] Avoid unecessary copying the parameter Using forwarding reference here so that we won't get unnecessary copies of the parameter passed to `slot`, for example a lambda function. --- src/base/net/downloadmanager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base/net/downloadmanager.h b/src/base/net/downloadmanager.h index b92ad3e95..a4fd7b2ac 100644 --- a/src/base/net/downloadmanager.h +++ b/src/base/net/downloadmanager.h @@ -119,7 +119,7 @@ namespace Net static DownloadManager *instance(); template - void download(const DownloadRequest &downloadRequest, Context context, Func slot); + void download(const DownloadRequest &downloadRequest, Context context, Func &&slot); void registerSequentialService(const ServiceID &serviceID); @@ -150,7 +150,7 @@ namespace Net }; template - void DownloadManager::download(const DownloadRequest &downloadRequest, Context context, Func slot) + void DownloadManager::download(const DownloadRequest &downloadRequest, Context context, Func &&slot) { const DownloadHandler *handler = download(downloadRequest); connect(handler, &DownloadHandler::finished, context, slot);