From f3ce76110b75730a790e5d2e6055910d9ed8cc2f Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 26 Aug 2019 14:25:16 +0800 Subject: [PATCH] Simplify code Instead of using dict_find_list() now we use the simpler dict_find() since we are going to check its validness anyway. --- src/base/bittorrent/session.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 934eaf14f..80bcd1467 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -171,11 +171,6 @@ namespace return output; } - bool isList(const lt::bdecode_node &entry) - { - return entry.type() == lt::bdecode_node::list_t; - } - QSet entryListToSet(const lt::bdecode_node &entry) { return entryListToSetImpl(entry); @@ -3667,13 +3662,13 @@ void Session::startUpTorrents() QStringList fastresumes = resumeDataDir.entryList( QStringList(QLatin1String("*.fastresume")), QDir::Files, QDir::Unsorted); - typedef struct + struct TorrentResumeData { QString hash; MagnetUri magnetUri; CreateTorrentParams addTorrentData; QByteArray data; - } TorrentResumeData; + }; int resumedTorrentsCount = 0; const auto startupTorrent = [this, &resumeDataDir, &resumedTorrentsCount](const TorrentResumeData ¶ms) @@ -4452,9 +4447,9 @@ namespace if (torrentParams.category.isEmpty()) // ************************************************************************************** torrentParams.category = fromLTString(fast.dict_find_string_value("qBt-category")); - // auto because the return type depends on the #if above. - const auto tagsEntry = fast.dict_find_list("qBt-tags"); - if (isList(tagsEntry)) + + const lt::bdecode_node tagsEntry = fast.dict_find("qBt-tags"); + if (tagsEntry.type() == lt::bdecode_node::list_t) torrentParams.tags = entryListToSet(tagsEntry); torrentParams.name = fromLTString(fast.dict_find_string_value("qBt-name")); torrentParams.hasSeedStatus = fast.dict_find_int_value("qBt-seedStatus");