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.
This commit is contained in:
Chocobo1 2019-08-26 01:21:36 +08:00
parent aeabd2d625
commit 0891cd4878
No known key found for this signature in database
GPG key ID: 210D9C873253A68C

View file

@ -119,7 +119,7 @@ namespace Net
static DownloadManager *instance();
template <typename Context, typename Func>
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 <typename Context, typename Func>
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);