mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 14:23:35 -07:00
refactor(setTags): optimize loop
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
This commit is contained in:
parent
58b7f2bf5a
commit
51cabe99df
1 changed files with 4 additions and 2 deletions
|
@ -1482,12 +1482,14 @@ void TorrentsController::setTagsAction()
|
|||
const QStringList hashes {params()[u"hashes"_s].split(u'|', Qt::SkipEmptyParts)};
|
||||
const QStringList tags {params()[u"tags"_s].split(u',', Qt::SkipEmptyParts)};
|
||||
|
||||
const TagSet newTags {tags.begin(), tags.end()};
|
||||
TagSet newTags {tags.begin(), tags.end()};
|
||||
applyToTorrents(hashes, [&newTags](BitTorrent::Torrent *const torrent)
|
||||
{
|
||||
for (const Tag &tag : asConst(torrent->tags()))
|
||||
if (!newTags.contains(tag))
|
||||
{
|
||||
if (newTags.erase(tag) == 0)
|
||||
torrent->removeTag(tag);
|
||||
}
|
||||
for (const Tag &tag : newTags)
|
||||
torrent->addTag(tag);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue