mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 16:37:21 -06:00
Avoid heavy weight function object
Also, by switching to template we can avoid the cost of converting to some specific type and perfectly forward the parameter to the final function. PR #21572.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "torrentscontroller.h"
|
||||
|
||||
#include <concepts>
|
||||
#include <functional>
|
||||
|
||||
#include <QBitArray>
|
||||
@@ -135,7 +136,9 @@ namespace
|
||||
|
||||
const QSet<QString> SUPPORTED_WEB_SEED_SCHEMES {u"http"_s, u"https"_s, u"ftp"_s};
|
||||
|
||||
void applyToTorrents(const QStringList &idList, const std::function<void (BitTorrent::Torrent *torrent)> &func)
|
||||
template <typename Func>
|
||||
void applyToTorrents(const QStringList &idList, Func func)
|
||||
requires std::invocable<Func, BitTorrent::Torrent *>
|
||||
{
|
||||
if ((idList.size() == 1) && (idList[0] == u"all"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user