Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid repetitive function calls #20764

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/base/torrentfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ bool TorrentFilter::match(const Torrent *const torrent) const

bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const
{
const BitTorrent::TorrentState state = torrent->state();

switch (m_type)
{
case All:
default:
return true;
case Downloading:
return torrent->isDownloading();
Expand All @@ -176,20 +177,23 @@ bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const
case Inactive:
return torrent->isInactive();
case Stalled:
return (torrent->state() == BitTorrent::TorrentState::StalledUploading)
|| (torrent->state() == BitTorrent::TorrentState::StalledDownloading);
return (state == BitTorrent::TorrentState::StalledUploading)
|| (state == BitTorrent::TorrentState::StalledDownloading);
case StalledUploading:
return torrent->state() == BitTorrent::TorrentState::StalledUploading;
return state == BitTorrent::TorrentState::StalledUploading;
case StalledDownloading:
return torrent->state() == BitTorrent::TorrentState::StalledDownloading;
return state == BitTorrent::TorrentState::StalledDownloading;
case Checking:
return (torrent->state() == BitTorrent::TorrentState::CheckingUploading)
|| (torrent->state() == BitTorrent::TorrentState::CheckingDownloading)
|| (torrent->state() == BitTorrent::TorrentState::CheckingResumeData);
return (state == BitTorrent::TorrentState::CheckingUploading)
|| (state == BitTorrent::TorrentState::CheckingDownloading)
|| (state == BitTorrent::TorrentState::CheckingResumeData);
case Moving:
return torrent->isMoving();
case Errored:
return torrent->isErrored();
default:
Q_ASSERT(false);
return false;
}
}

Expand Down