Don't create a temporary QSet to check the blacklist
This commit is contained in:
parent
08b32208f0
commit
8545ad84a8
1 changed files with 8 additions and 13 deletions
|
@ -87,7 +87,7 @@ void DanbooruService::getPostList(int page, QStringList tags, int limit)
|
||||||
QUrl danbooruUrl = requestUrl(m_url, POST_URL, m_username,
|
QUrl danbooruUrl = requestUrl(m_url, POST_URL, m_username,
|
||||||
m_password, parameters, tags);
|
m_password, parameters, tags);
|
||||||
|
|
||||||
//qDebug() << "Final constructed post URL" << danbooruUrl.url();
|
// qDebug() << "Final constructed post URL" << danbooruUrl.url();
|
||||||
|
|
||||||
KIO::StoredTransferJob* job = KIO::storedGet(danbooruUrl, KIO::NoReload,
|
KIO::StoredTransferJob* job = KIO::storedGet(danbooruUrl, KIO::NoReload,
|
||||||
KIO::HideProgressInfo);
|
KIO::HideProgressInfo);
|
||||||
|
@ -283,7 +283,7 @@ const DanbooruPost::Ratings DanbooruService::maximumAllowedRating() const
|
||||||
void DanbooruService::processPostList(KJob* job)
|
void DanbooruService::processPostList(KJob* job)
|
||||||
{
|
{
|
||||||
|
|
||||||
////qDebug() << "Got post data OK";
|
// qDebug() << "Got post data OK";
|
||||||
|
|
||||||
if (job->error()) {
|
if (job->error()) {
|
||||||
Q_EMIT(downloadError(job->errorString()));
|
Q_EMIT(downloadError(job->errorString()));
|
||||||
|
@ -335,18 +335,13 @@ void DanbooruService::processPostList(KJob* job)
|
||||||
}
|
}
|
||||||
|
|
||||||
// second check, blacklist
|
// second check, blacklist
|
||||||
// We make a copy due to the fact that otherwise intersect()
|
|
||||||
// will change the set in place
|
|
||||||
|
|
||||||
QSet<QString> temp = m_blacklist;
|
for (auto tag: post->tags()) {
|
||||||
|
if (m_blacklist.contains(tag)) {
|
||||||
temp = temp.intersect(post->tags());
|
m_currentPosts--;
|
||||||
|
delete post;
|
||||||
if (!temp.isEmpty()) {
|
continue;
|
||||||
// Blacklisted tags are present, do not use this post
|
}
|
||||||
m_currentPosts--;
|
|
||||||
delete post;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap pix;
|
QPixmap pix;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue