From ef4a72d38304142578b06eae5250ae083be98a5f Mon Sep 17 00:00:00 2001 From: Andrey Prygunkov Date: Wed, 13 Jan 2016 00:32:38 +0100 Subject: [PATCH] =?UTF-8?q?#152:=20eliminated=20dereferences=20in=20for-ra?= =?UTF-8?q?nge=20loops=20using=20=E2=80=9Cbegin()=E2=80=9D=20and=20?= =?UTF-8?q?=E2=80=9Cend()=E2=80=9D=20template=20functions=20in=20=E2=80=9C?= =?UTF-8?q?nzbget.h=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- daemon/extension/NzbScript.cpp | 4 +- daemon/extension/PostScript.cpp | 4 +- daemon/extension/QueueScript.cpp | 8 +-- daemon/extension/ScriptConfig.cpp | 4 +- daemon/feed/FeedCoordinator.cpp | 6 +-- daemon/feed/FeedInfo.cpp | 4 +- daemon/frontend/Frontend.cpp | 2 +- daemon/frontend/NCursesFrontend.cpp | 14 ++--- daemon/main/Options.cpp | 8 +-- daemon/main/Scheduler.cpp | 8 +-- daemon/main/nzbget.h | 8 +++ daemon/nntp/ArticleDownloader.cpp | 4 +- daemon/nntp/ArticleWriter.cpp | 14 ++--- daemon/nntp/ServerPool.cpp | 2 +- daemon/postprocess/ParChecker.cpp | 4 +- daemon/postprocess/ParCoordinator.cpp | 16 +++--- daemon/postprocess/ParParser.cpp | 2 +- daemon/postprocess/PrePostProcessor.cpp | 6 +-- daemon/queue/DiskState.cpp | 70 ++++++++++++------------- daemon/queue/DownloadInfo.cpp | 24 ++++----- daemon/queue/DupeCoordinator.cpp | 22 ++++---- daemon/queue/HistoryCoordinator.cpp | 4 +- daemon/queue/NzbFile.cpp | 12 ++--- daemon/queue/QueueCoordinator.cpp | 34 ++++++------ daemon/queue/QueueEditor.cpp | 42 +++++++-------- daemon/queue/Scanner.cpp | 4 +- daemon/queue/UrlCoordinator.cpp | 2 +- daemon/remote/BinRpc.cpp | 30 +++++------ daemon/remote/RemoteClient.cpp | 12 ++--- daemon/remote/XmlRpc.cpp | 34 ++++++------ daemon/util/Script.cpp | 2 +- daemon/windows/WinConsole.cpp | 4 +- 32 files changed, 211 insertions(+), 203 deletions(-) diff --git a/daemon/extension/NzbScript.cpp b/daemon/extension/NzbScript.cpp index 5fc3078c..87b6754c 100644 --- a/daemon/extension/NzbScript.cpp +++ b/daemon/extension/NzbScript.cpp @@ -38,7 +38,7 @@ void NzbScriptController::PrepareEnvParameters(NzbParameterList* parameters, con { int prefixLen = stripPrefix ? strlen(stripPrefix) : 0; - for (NzbParameter& parameter : *parameters) + for (NzbParameter& parameter : parameters) { const char* value = parameter.GetValue(); @@ -72,7 +72,7 @@ void NzbScriptController::PrepareEnvScript(NzbParameterList* parameters, const c void NzbScriptController::ExecuteScriptList(const char* scriptList) { - for (ScriptConfig::Script& script : *g_ScriptConfig->GetScripts()) + for (ScriptConfig::Script& script : g_ScriptConfig->GetScripts()) { if (scriptList && *scriptList) { diff --git a/daemon/extension/PostScript.cpp b/daemon/extension/PostScript.cpp index 187e76d7..3bdd3394 100644 --- a/daemon/extension/PostScript.cpp +++ b/daemon/extension/PostScript.cpp @@ -53,7 +53,7 @@ void PostScriptController::Run() // the locking is needed for accessing the members of NZBInfo DownloadQueue::Lock(); - for (NzbParameter& parameter : *m_postInfo->GetNzbInfo()->GetParameters()) + for (NzbParameter& parameter : m_postInfo->GetNzbInfo()->GetParameters()) { const char* varname = parameter.GetName(); if (strlen(varname) > 0 && varname[0] != '*' && varname[strlen(varname)-1] == ':' && @@ -170,7 +170,7 @@ void PostScriptController::PrepareParams(const char* scriptName) SetIntEnvVar("NZBPP_SUCCESSARTICLES", (int)m_postInfo->GetNzbInfo()->GetSuccessArticles()); SetIntEnvVar("NZBPP_FAILEDARTICLES", (int)m_postInfo->GetNzbInfo()->GetFailedArticles()); - for (ServerStat& serverStat : *m_postInfo->GetNzbInfo()->GetServerStats()) + for (ServerStat& serverStat : m_postInfo->GetNzbInfo()->GetServerStats()) { SetIntEnvVar(BString<1024>("NZBPP_SERVER%i_SUCCESSARTICLES", serverStat.GetServerId()), serverStat.GetSuccessArticles()); diff --git a/daemon/extension/QueueScript.cpp b/daemon/extension/QueueScript.cpp index c56bdc7e..4a4bd428 100644 --- a/daemon/extension/QueueScript.cpp +++ b/daemon/extension/QueueScript.cpp @@ -243,7 +243,7 @@ QueueScriptCoordinator::~QueueScriptCoordinator() void QueueScriptCoordinator::InitOptions() { m_hasQueueScripts = false; - for (ScriptConfig::Script& script : *g_ScriptConfig->GetScripts()) + for (ScriptConfig::Script& script : g_ScriptConfig->GetScripts()) { if (script.GetQueueScript()) { @@ -289,7 +289,7 @@ void QueueScriptCoordinator::EnqueueScript(NzbInfo* nzbInfo, EEvent event) return; } - for (ScriptConfig::Script& script : *g_ScriptConfig->GetScripts()) + for (ScriptConfig::Script& script : g_ScriptConfig->GetScripts()) { if (!script.GetQueueScript()) { @@ -317,7 +317,7 @@ void QueueScriptCoordinator::EnqueueScript(NzbInfo* nzbInfo, EEvent event) // check post-processing-scripts if (!useScript) { - for (NzbParameter& parameter : *nzbInfo->GetParameters()) + for (NzbParameter& parameter : nzbInfo->GetParameters()) { const char* varname = parameter.GetName(); if (strlen(varname) > 0 && varname[0] != '*' && varname[strlen(varname)-1] == ':' && @@ -379,7 +379,7 @@ NzbInfo* QueueScriptCoordinator::FindNzbInfo(DownloadQueue* downloadQueue, int n NzbInfo* nzbInfo = downloadQueue->GetQueue()->Find(nzbId); if (!nzbInfo) { - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetNzbInfo() && historyInfo->GetNzbInfo()->GetId() == nzbId) { diff --git a/daemon/extension/ScriptConfig.cpp b/daemon/extension/ScriptConfig.cpp index 077858b9..6f922c0d 100644 --- a/daemon/extension/ScriptConfig.cpp +++ b/daemon/extension/ScriptConfig.cpp @@ -400,14 +400,14 @@ void ScriptConfig::BuildScriptDisplayNames(Scripts* scripts) // trying to use short name without path and extension. // if there are other scripts with the same short name - using a longer name instead (with ot without extension) - for (Script& script : *scripts) + for (Script& script : scripts) { BString<1024> shortName = script.GetName(); if (char* ext = strrchr(shortName, '.')) *ext = '\0'; // strip file extension const char* displayName = FileSystem::BaseFileName(shortName); - for (Script& script2 : *scripts) + for (Script& script2 : scripts) { BString<1024> shortName2 = script2.GetName(); if (char* ext = strrchr(shortName2, '.')) *ext = '\0'; // strip file extension diff --git a/daemon/feed/FeedCoordinator.cpp b/daemon/feed/FeedCoordinator.cpp index def28b35..7e5617f6 100644 --- a/daemon/feed/FeedCoordinator.cpp +++ b/daemon/feed/FeedCoordinator.cpp @@ -411,7 +411,7 @@ void FeedCoordinator::FilterFeed(FeedInfo* feedInfo, FeedItemInfos* feedItemInfo feedFilter = new FeedFilter(feedInfo->GetFilter()); } - for (FeedItemInfo& feedItemInfo : *feedItemInfos) + for (FeedItemInfo& feedItemInfo : feedItemInfos) { feedItemInfo.SetMatchStatus(FeedItemInfo::msAccepted); feedItemInfo.SetMatchRule(0); @@ -440,7 +440,7 @@ void FeedCoordinator::ProcessFeed(FeedInfo* feedInfo, FeedItemInfos* feedItemInf bool firstFetch = feedInfo->GetLastUpdate() == 0; int added = 0; - for (FeedItemInfo& feedItemInfo : *feedItemInfos) + for (FeedItemInfo& feedItemInfo : feedItemInfos) { if (feedItemInfo.GetMatchStatus() == FeedItemInfo::msAccepted) { @@ -604,7 +604,7 @@ bool FeedCoordinator::PreviewFeed(int id, const char* name, const char* url, con feedItemInfos->Retain(); delete feedFile; - for (FeedItemInfo& feedItemInfo : *feedItemInfos) + for (FeedItemInfo& feedItemInfo : feedItemInfos) { feedItemInfo.SetStatus(firstFetch && feedInfo->GetBacklog() ? FeedItemInfo::isBacklog : FeedItemInfo::isNew); FeedHistoryInfo* feedHistoryInfo = m_feedHistory.Find(feedItemInfo.GetUrl()); diff --git a/daemon/feed/FeedInfo.cpp b/daemon/feed/FeedInfo.cpp index 08a83ae8..b8b4e8da 100644 --- a/daemon/feed/FeedInfo.cpp +++ b/daemon/feed/FeedInfo.cpp @@ -51,7 +51,7 @@ FeedInfo::FeedInfo(int id, const char* name, const char* url, bool backlog, int FeedItemInfo::Attr* FeedItemInfo::Attributes::Find(const char* name) { - for (Attr& attr : *this) + for (Attr& attr : this) { if (!strcasecmp(attr.GetName(), name)) { @@ -221,7 +221,7 @@ void FeedHistory::Remove(const char* url) FeedHistoryInfo* FeedHistory::Find(const char* url) { - for (FeedHistoryInfo& feedHistoryInfo : *this) + for (FeedHistoryInfo& feedHistoryInfo : this) { if (!strcmp(feedHistoryInfo.GetUrl(), url)) { diff --git a/daemon/frontend/Frontend.cpp b/daemon/frontend/Frontend.cpp index bf9009bd..c5ef28d4 100644 --- a/daemon/frontend/Frontend.cpp +++ b/daemon/frontend/Frontend.cpp @@ -83,7 +83,7 @@ bool Frontend::PrepareData() DownloadQueue *downloadQueue = DownloadQueue::Lock(); m_postJobCount = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { m_postJobCount += nzbInfo->GetPostInfo() ? 1 : 0; } diff --git a/daemon/frontend/NCursesFrontend.cpp b/daemon/frontend/NCursesFrontend.cpp index 3e2f8faf..957871a3 100644 --- a/daemon/frontend/NCursesFrontend.cpp +++ b/daemon/frontend/NCursesFrontend.cpp @@ -373,7 +373,7 @@ int NCursesFrontend::CalcQueueSize() } else { - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { queueSize += nzbInfo->GetFileList()->size(); } @@ -695,9 +695,9 @@ void NCursesFrontend::PrintFileQueue() int pausedFiles = 0; int fileNum = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (fileNum >= m_queueScrollOffset && fileNum < m_queueScrollOffset + m_queueWinHeight -1) { @@ -859,7 +859,7 @@ void NCursesFrontend::PrintGroupQueue() ResetColWidths(); int calcLineNr = lineNr; int i = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { if (i >= m_queueScrollOffset && i < m_queueScrollOffset + m_queueWinHeight -1) { @@ -871,7 +871,7 @@ void NCursesFrontend::PrintGroupQueue() int64 remaining = 0; int64 paused = 0; i = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { if (i >= m_queueScrollOffset && i < m_queueScrollOffset + m_queueWinHeight -1) { @@ -1054,9 +1054,9 @@ bool NCursesFrontend::EditQueue(DownloadQueue::EEditAction action, int offset) DownloadQueue* downloadQueue = LockQueue(); int fileNum = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (m_selectedQueueEntry == fileNum) { diff --git a/daemon/main/Options.cpp b/daemon/main/Options.cpp index aef26a23..4109c9cd 100644 --- a/daemon/main/Options.cpp +++ b/daemon/main/Options.cpp @@ -211,7 +211,7 @@ Options::OptEntry* Options::OptEntries::FindOption(const char* name) return nullptr; } - for (OptEntry& optEntry : *this) + for (OptEntry& optEntry : this) { if (!strcasecmp(optEntry.GetName(), name)) { @@ -230,7 +230,7 @@ Options::Category* Options::Categories::FindCategory(const char* name, bool sear return nullptr; } - for (Category& category : *this) + for (Category& category : this) { if (!strcasecmp(category.GetName(), name)) { @@ -240,9 +240,9 @@ Options::Category* Options::Categories::FindCategory(const char* name, bool sear if (searchAliases) { - for (Category& category : *this) + for (Category& category : this) { - for (CString& alias : *category.GetAliases()) + for (CString& alias : category.GetAliases()) { WildMask mask(alias); if (mask.Match(name)) diff --git a/daemon/main/Scheduler.cpp b/daemon/main/Scheduler.cpp index a6900c6b..144955fd 100644 --- a/daemon/main/Scheduler.cpp +++ b/daemon/main/Scheduler.cpp @@ -278,7 +278,7 @@ void Scheduler::PrintLog() if (m_serverChanged) { int index = 0; - for (NewsServer* server : *g_ServerPool->GetServers()) + for (NewsServer* server : g_ServerPool->GetServers()) { if (server->GetActive() != m_serverStatusList[index]) { @@ -296,7 +296,7 @@ void Scheduler::EditServer(bool active, const char* serverList) while (const char* serverRef = tok.Next()) { int id = atoi(serverRef); - for (NewsServer* server : *g_ServerPool->GetServers()) + for (NewsServer* server : g_ServerPool->GetServers()) { if ((id > 0 && server->GetId() == id) || !strcasecmp(server->GetName(), serverRef)) @@ -306,7 +306,7 @@ void Scheduler::EditServer(bool active, const char* serverList) // store old server status for logging m_serverStatusList.clear(); m_serverStatusList.reserve(g_ServerPool->GetServers()->size()); - for (NewsServer* server2 : *g_ServerPool->GetServers()) + for (NewsServer* server2 : g_ServerPool->GetServers()) { m_serverStatusList.push_back(server2->GetActive()); } @@ -325,7 +325,7 @@ void Scheduler::FetchFeed(const char* feedList) while (const char* feedRef = tok.Next()) { int id = atoi(feedRef); - for (FeedInfo* feed : *g_FeedCoordinator->GetFeeds()) + for (FeedInfo* feed : g_FeedCoordinator->GetFeeds()) { if (feed->GetId() == id || !strcasecmp(feed->GetName(), feedRef) || diff --git a/daemon/main/nzbget.h b/daemon/main/nzbget.h index c371db9c..aece8f45 100644 --- a/daemon/main/nzbget.h +++ b/daemon/main/nzbget.h @@ -338,4 +338,12 @@ typedef unsigned char uchar; #define PRINTF_SYNTAX(strindex) #endif +// for-range loops on pointers to std-containers (avoiding dereferencing) +template typename std::deque::iterator begin(std::deque* c) { return c->begin(); } +template typename std::deque::iterator end(std::deque* c) { return c->end(); } +template typename std::vector::iterator begin(std::vector* c) { return c->begin(); } +template typename std::vector::iterator end(std::vector* c) { return c->end(); } +template typename std::list::iterator begin(std::list* c) { return c->begin(); } +template typename std::list::iterator end(std::list* c) { return c->end(); } + #endif /* NZBGET_H */ diff --git a/daemon/nntp/ArticleDownloader.cpp b/daemon/nntp/ArticleDownloader.cpp index 044143a9..2bbd9f61 100644 --- a/daemon/nntp/ArticleDownloader.cpp +++ b/daemon/nntp/ArticleDownloader.cpp @@ -217,7 +217,7 @@ void ArticleDownloader::Run() // if all servers from all levels were tried, break the loop with failure status bool allServersOnLevelFailed = true; - for (NewsServer* candidateServer : *g_ServerPool->GetServers()) + for (NewsServer* candidateServer : g_ServerPool->GetServers()) { if (candidateServer->GetNormLevel() == level) { @@ -301,7 +301,7 @@ ArticleDownloader::EStatus ArticleDownloader::Download() if (m_connection->GetNewsServer()->GetJoinGroup()) { // change group - for (CString& group : *m_fileInfo->GetGroups()) + for (CString& group : m_fileInfo->GetGroups()) { response = m_connection->JoinGroup(group); if (response && !strncmp(response, "2", 1)) diff --git a/daemon/nntp/ArticleWriter.cpp b/daemon/nntp/ArticleWriter.cpp index b249b2f3..200bddcd 100644 --- a/daemon/nntp/ArticleWriter.cpp +++ b/daemon/nntp/ArticleWriter.cpp @@ -411,7 +411,7 @@ void ArticleWriter::CompleteFileParts() buffer = (char*)malloc(BUFFER_SIZE); } - for (ArticleInfo* pa : *m_fileInfo->GetArticles()) + for (ArticleInfo* pa : m_fileInfo->GetArticles()) { if (pa->GetStatus() != ArticleInfo::aiFinished) { @@ -521,7 +521,7 @@ void ArticleWriter::CompleteFileParts() if (!directWrite) { - for (ArticleInfo* pa : *m_fileInfo->GetArticles()) + for (ArticleInfo* pa : m_fileInfo->GetArticles()) { FileSystem::DeleteFile(pa->GetResultFilename()); } @@ -592,7 +592,7 @@ void ArticleWriter::FlushCache() cachedArticles.reserve(m_fileInfo->GetArticles()->size()); g_ArticleCache->LockContent(); - for (ArticleInfo* pa : *m_fileInfo->GetArticles()) + for (ArticleInfo* pa : m_fileInfo->GetArticles()) { if (pa->GetSegmentContent()) { @@ -695,7 +695,7 @@ bool ArticleWriter::MoveCompletedFiles(NzbInfo* nzbInfo, const char* oldDestDir) } // move already downloaded files to new destination - for (CompletedFile& completedFile : *nzbInfo->GetCompletedFiles()) + for (CompletedFile& completedFile : nzbInfo->GetCompletedFiles()) { BString<1024> oldFileName("%s%c%s", oldDestDir, (int)PATH_SEPARATOR, completedFile.GetFileName()); BString<1024> newFileName("%s%c%s", nzbInfo->GetDestDir(), (int)PATH_SEPARATOR, completedFile.GetFileName()); @@ -773,7 +773,7 @@ bool ArticleWriter::MoveCompletedFiles(NzbInfo* nzbInfo, const char* oldDestDir) { // check if there are pending writes into directory bool pendingWrites = false; - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (!pendingWrites) { @@ -903,14 +903,14 @@ bool ArticleCache::CheckFlush(bool flushEverything) BString<1024> infoName; DownloadQueue* downloadQueue = DownloadQueue::Lock(); - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { if (m_fileInfo) { break; } - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (fileInfo->GetCachedArticles() > 0 && (fileInfo->GetActiveDownloads() == 0 || flushEverything)) { diff --git a/daemon/nntp/ServerPool.cpp b/daemon/nntp/ServerPool.cpp index ef0af291..2832ead3 100644 --- a/daemon/nntp/ServerPool.cpp +++ b/daemon/nntp/ServerPool.cpp @@ -213,7 +213,7 @@ NntpConnection* ServerPool::GetConnection(int level, NewsServer* wantServer, Ser bool useConnection = true; if (ignoreServers && !wantServer) { - for (NewsServer* ignoreServer : *ignoreServers) + for (NewsServer* ignoreServer : ignoreServers) { if (ignoreServer == candidateServer || (ignoreServer->GetGroup() > 0 && ignoreServer->GetGroup() == candidateServer->GetGroup() && diff --git a/daemon/postprocess/ParChecker.cpp b/daemon/postprocess/ParChecker.cpp index 697acd96..cdbc6502 100644 --- a/daemon/postprocess/ParChecker.cpp +++ b/daemon/postprocess/ParChecker.cpp @@ -1410,7 +1410,7 @@ bool ParChecker::VerifyPartialDataFile(void* diskfile, void* sourcefile, Segment bool blockOK = false; bool blockEndFound = false; Par2::u64 curOffset = 0; - for (Segment& segment : *segments) + for (Segment& segment : segments) { if (!blockOK && segment.GetSuccess() && segment.GetOffset() <= blockStart && segment.GetOffset() + segment.GetSize() >= blockStart) @@ -1505,7 +1505,7 @@ bool ParChecker::SmartCalcFileRangeCrc(DiskFile& file, int64 start, int64 end, S { uint32 downloadCrc = 0; bool started = false; - for (Segment& segment : *segments) + for (Segment& segment : segments) { if (!started && segment.GetOffset() > start) { diff --git a/daemon/postprocess/ParCoordinator.cpp b/daemon/postprocess/ParCoordinator.cpp index d33dc6b6..06d2632d 100644 --- a/daemon/postprocess/ParCoordinator.cpp +++ b/daemon/postprocess/ParCoordinator.cpp @@ -62,7 +62,7 @@ void ParCoordinator::PostParChecker::RegisterParredFile(const char* filename) bool ParCoordinator::PostParChecker::IsParredFile(const char* filename) { - for (CString& parredFile : *m_postInfo->GetParredFiles()) + for (CString& parredFile : m_postInfo->GetParredFiles()) { if (!strcasecmp(parredFile, filename)) { @@ -77,7 +77,7 @@ ParChecker::EFileStatus ParCoordinator::PostParChecker::FindFileCrc(const char* { CompletedFile* completedFile = nullptr; - for (CompletedFile& completedFile2 : *m_postInfo->GetNzbInfo()->GetCompletedFiles()) + for (CompletedFile& completedFile2 : m_postInfo->GetNzbInfo()->GetCompletedFiles()) { if (!strcasecmp(completedFile2.GetFileName(), filename)) { @@ -105,7 +105,7 @@ ParChecker::EFileStatus ParCoordinator::PostParChecker::FindFileCrc(const char* return ParChecker::fsUnknown; } - for (ArticleInfo* pa : *tmpFileInfo->GetArticles()) + for (ArticleInfo* pa : tmpFileInfo->GetArticles()) { segments->emplace_back(pa->GetStatus() == ArticleInfo::aiFinished, pa->GetSegmentOffset(), pa->GetSegmentSize(), pa->GetCrc()); @@ -161,11 +161,11 @@ void ParCoordinator::PostParChecker::StatDupeSources(DupeSourceList* dupeSourceL DownloadQueue* downloadQueue = DownloadQueue::Lock(); int totalExtraParBlocks = 0; - for (DupeSource& dupeSource : *dupeSourceList) + for (DupeSource& dupeSource : dupeSourceList) { if (dupeSource.GetUsedBlocks() > 0) { - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() == HistoryInfo::hkNzb && historyInfo->GetNzbInfo()->GetId() == dupeSource.GetId()) @@ -209,7 +209,7 @@ void ParCoordinator::PostParRenamer::RegisterParredFile(const char* filename) */ void ParCoordinator::PostParRenamer::RegisterRenamedFile(const char* oldFilename, const char* newFileName) { - for (CompletedFile& completedFile : *m_postInfo->GetNzbInfo()->GetCompletedFiles()) + for (CompletedFile& completedFile : m_postInfo->GetNzbInfo()->GetCompletedFiles()) { if (!strcasecmp(completedFile.GetFileName(), oldFilename)) { @@ -492,7 +492,7 @@ bool ParCoordinator::RequestMorePars(NzbInfo* nzbInfo, const char* parFilename, } bool hasUnpausedParFiles = false; - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (fileInfo->GetParFile() && !fileInfo->GetPaused()) { @@ -531,7 +531,7 @@ void ParCoordinator::FindPars(DownloadQueue* downloadQueue, NzbInfo* nzbInfo, co mainBaseFilename.Set(baseParFilename, mainBaseLen); for (char* p = mainBaseFilename; *p; p++) *p = tolower(*p); // convert string to lowercase - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { int blockCount = 0; if (ParParser::ParseParFilename(fileInfo->GetFilename(), nullptr, &blockCount) && diff --git a/daemon/postprocess/ParParser.cpp b/daemon/postprocess/ParParser.cpp index fc2ab1f6..f0c42b06 100644 --- a/daemon/postprocess/ParParser.cpp +++ b/daemon/postprocess/ParParser.cpp @@ -47,7 +47,7 @@ bool ParParser::FindMainPars(const char* path, ParFileList* fileList) // check if the base file already added to list bool exists = false; - for (CString& filename2 : *fileList) + for (CString& filename2 : fileList) { exists = SameParCollection(filename, filename2); if (exists) diff --git a/daemon/postprocess/PrePostProcessor.cpp b/daemon/postprocess/PrePostProcessor.cpp index 2c814752..5725dbe5 100644 --- a/daemon/postprocess/PrePostProcessor.cpp +++ b/daemon/postprocess/PrePostProcessor.cpp @@ -445,7 +445,7 @@ NzbInfo* PrePostProcessor::GetNextJob(DownloadQueue* downloadQueue) */ void PrePostProcessor::SanitisePostQueue(DownloadQueue* downloadQueue) { - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { PostInfo* postInfo = nzbInfo->GetPostInfo(); if (postInfo) @@ -680,7 +680,7 @@ bool PrePostProcessor::IsNzbFileCompleted(NzbInfo* nzbInfo, bool ignorePausedPar { int deleted = 0; - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (fileInfo->GetDeleted()) { @@ -704,7 +704,7 @@ bool PrePostProcessor::IsNzbFileDownloading(NzbInfo* nzbInfo) return true; } - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (!fileInfo->GetPaused()) { diff --git a/daemon/queue/DiskState.cpp b/daemon/queue/DiskState.cpp index 27f0acb8..cd945f44 100644 --- a/daemon/queue/DiskState.cpp +++ b/daemon/queue/DiskState.cpp @@ -358,7 +358,7 @@ void DiskState::CompleteNzbList12(DownloadQueue* downloadQueue, NzbList* nzbList // here we renumber NZBIDs in order to keep them low. NzbInfo::ResetGenId(false); int id = 1; - for (NzbInfo* nzbInfo : *nzbList) + for (NzbInfo* nzbInfo : nzbList) { nzbInfo->SetId(id++); } @@ -369,7 +369,7 @@ void DiskState::CompleteDupList12(DownloadQueue* downloadQueue, int formatVersio { NzbInfo::ResetGenId(true); - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() == HistoryInfo::hkDup) { @@ -383,7 +383,7 @@ void DiskState::SaveNzbQueue(DownloadQueue* downloadQueue, DiskFile& outfile) debug("Saving nzb list to disk"); outfile.Print("%i\n", (int)downloadQueue->GetQueue()->size()); - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { SaveNzbInfo(nzbInfo, outfile); } @@ -460,20 +460,20 @@ void DiskState::SaveNzbInfo(NzbInfo* nzbInfo, DiskFile& outfile) nzbInfo->GetParSec(), nzbInfo->GetRepairSec(), nzbInfo->GetUnpackSec()); outfile.Print("%i\n", (int)nzbInfo->GetCompletedFiles()->size()); - for (CompletedFile& completedFile : *nzbInfo->GetCompletedFiles()) + for (CompletedFile& completedFile : nzbInfo->GetCompletedFiles()) { outfile.Print("%i,%i,%u,%s\n", completedFile.GetId(), (int)completedFile.GetStatus(), completedFile.GetCrc(), completedFile.GetFileName()); } outfile.Print("%i\n", (int)nzbInfo->GetParameters()->size()); - for (NzbParameter& parameter : *nzbInfo->GetParameters()) + for (NzbParameter& parameter : nzbInfo->GetParameters()) { outfile.Print("%s=%s\n", parameter.GetName(), parameter.GetValue()); } outfile.Print("%i\n", (int)nzbInfo->GetScriptStatuses()->size()); - for (ScriptStatus& scriptStatus : *nzbInfo->GetScriptStatuses()) + for (ScriptStatus& scriptStatus : nzbInfo->GetScriptStatuses()) { outfile.Print("%i,%s\n", scriptStatus.GetStatus(), scriptStatus.GetName()); } @@ -482,7 +482,7 @@ void DiskState::SaveNzbInfo(NzbInfo* nzbInfo, DiskFile& outfile) // save file-infos int size = 0; - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (!fileInfo->GetDeleted()) { @@ -490,7 +490,7 @@ void DiskState::SaveNzbInfo(NzbInfo* nzbInfo, DiskFile& outfile) } } outfile.Print("%i\n", size); - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (!fileInfo->GetDeleted()) { @@ -1064,7 +1064,7 @@ error: void DiskState::SaveServerStats(ServerStatList* serverStatList, DiskFile& outfile) { outfile.Print("%i\n", (int)serverStatList->size()); - for (ServerStat& serverStat : *serverStatList) + for (ServerStat& serverStat : serverStatList) { outfile.Print("%i,%i,%i\n", serverStat.GetServerId(), serverStat.GetSuccessArticles(), serverStat.GetFailedArticles()); } @@ -1082,7 +1082,7 @@ bool DiskState::LoadServerStats(ServerStatList* serverStatList, Servers* servers if (servers) { // find server (id could change if config file was edited) - for (NewsServer* newsServer : *servers) + for (NewsServer* newsServer : servers) { if (newsServer->GetStateId() == serverId) { @@ -1133,13 +1133,13 @@ bool DiskState::SaveFileInfo(FileInfo* fileInfo, const char* filename) outfile.Print("%i,%i\n", fileInfo->GetTotalArticles(), fileInfo->GetMissedArticles()); outfile.Print("%i\n", (int)fileInfo->GetGroups()->size()); - for (CString& group : *fileInfo->GetGroups()) + for (CString& group : fileInfo->GetGroups()) { outfile.Print("%s\n", *group); } outfile.Print("%i\n", (int)fileInfo->GetArticles()->size()); - for (ArticleInfo* articleInfo : *fileInfo->GetArticles()) + for (ArticleInfo* articleInfo : fileInfo->GetArticles()) { outfile.Print("%i,%i\n", articleInfo->GetPartNumber(), articleInfo->GetSize()); outfile.Print("%s\n", articleInfo->GetMessageId()); @@ -1297,7 +1297,7 @@ bool DiskState::SaveFileState(FileInfo* fileInfo, bool completed) SaveServerStats(fileInfo->GetServerStats(), outfile); outfile.Print("%i\n", (int)fileInfo->GetArticles()->size()); - for (ArticleInfo* articleInfo : *fileInfo->GetArticles()) + for (ArticleInfo* articleInfo : fileInfo->GetArticles()) { outfile.Print("%i,%u,%i,%u\n", (int)articleInfo->GetStatus(), (uint32)articleInfo->GetSegmentOffset(), articleInfo->GetSegmentSize(), (uint32)articleInfo->GetCrc()); @@ -1414,14 +1414,14 @@ error: void DiskState::DiscardFiles(NzbInfo* nzbInfo) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { DiscardFile(fileInfo, true, true, true); } BString<1024> filename; - for (CompletedFile& completedFile : *nzbInfo->GetCompletedFiles()) + for (CompletedFile& completedFile : nzbInfo->GetCompletedFiles()) { if (completedFile.GetStatus() != CompletedFile::cfSuccess && completedFile.GetId() > 0) { @@ -1555,7 +1555,7 @@ bool DiskState::LoadPostQueue5(DownloadQueue* downloadQueue, NzbList* nzbList) // find NZBInfo based on NZBFilename NzbInfo* nzbInfo = nullptr; - for (NzbInfo* nzbInfo2 : *nzbList) + for (NzbInfo* nzbInfo2 : nzbList) { if (!strcmp(nzbInfo2->GetFilename(), buf)) { @@ -1812,7 +1812,7 @@ void DiskState::SaveHistory(DownloadQueue* downloadQueue, DiskFile& outfile) debug("Saving history to disk"); outfile.Print("%i\n", (int)downloadQueue->GetHistory()->size()); - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { outfile.Print("%i,%i,%i\n", historyInfo->GetId(), (int)historyInfo->GetKind(), (int)historyInfo->GetTime()); @@ -1933,7 +1933,7 @@ error: int DiskState::FindNzbInfoIndex(NzbList* nzbList, NzbInfo* nzbInfo) { int nzbIndex = 0; - for (NzbInfo* nzbInfo2 : *nzbList) + for (NzbInfo* nzbInfo2 : nzbList) { nzbIndex++; if (nzbInfo2 == nzbInfo) @@ -1949,7 +1949,7 @@ int DiskState::FindNzbInfoIndex(NzbList* nzbList, NzbInfo* nzbInfo) */ NzbInfo* DiskState::FindNzbInfo(DownloadQueue* downloadQueue, int id) { - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { if (nzbInfo->GetId() == id) { @@ -2123,7 +2123,7 @@ bool DiskState::SaveFeedStatus(Feeds* feeds, DiskFile& outfile) debug("Saving feed status to disk"); outfile.Print("%i\n", (int)feeds->size()); - for (FeedInfo* feedInfo : *feeds) + for (FeedInfo* feedInfo : feeds) { outfile.Print("%s\n", feedInfo->GetUrl()); outfile.Print("%u\n", feedInfo->GetFilterHash()); @@ -2161,7 +2161,7 @@ bool DiskState::LoadFeedStatus(Feeds* feeds, DiskFile& infile, int formatVersion int lastUpdate = 0; if (fscanf(infile, "%i\n", &lastUpdate) != 1) goto error; - for (FeedInfo* feedInfo : *feeds) + for (FeedInfo* feedInfo : feeds) { if (!strcmp(feedInfo->GetUrl(), url) && ((formatVersion == 1) || @@ -2185,7 +2185,7 @@ bool DiskState::SaveFeedHistory(FeedHistory* feedHistory, DiskFile& outfile) debug("Saving feed history to disk"); outfile.Print("%i\n", (int)feedHistory->size()); - for (FeedHistoryInfo& feedHistoryInfo : *feedHistory) + for (FeedHistoryInfo& feedHistoryInfo : feedHistory) { outfile.Print("%i,%i\n", (int)feedHistoryInfo.GetStatus(), (int)feedHistoryInfo.GetLastSeen()); outfile.Print("%s\n", feedHistoryInfo.GetUrl()); @@ -2225,13 +2225,13 @@ error: void DiskState::CalcCriticalHealth(NzbList* nzbList) { // build list of old NZBs which do not have critical health calculated - for (NzbInfo* nzbInfo : *nzbList) + for (NzbInfo* nzbInfo : nzbList) { if (nzbInfo->CalcCriticalHealth(false) == 1000) { debug("Calculating critical health for %s", nzbInfo->GetName()); - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { BString<1024> loFileName; loFileName = fileInfo->GetFilename(); @@ -2250,12 +2250,12 @@ void DiskState::CalcCriticalHealth(NzbList* nzbList) void DiskState::CalcFileStats(DownloadQueue* downloadQueue, int formatVersion) { - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { CalcNzbFileStats(nzbInfo, formatVersion); } - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() == HistoryInfo::hkNzb) { @@ -2277,7 +2277,7 @@ void DiskState::CalcNzbFileStats(NzbInfo* nzbInfo, int formatVersion) int64 parSuccessSize = 0; int64 parFailedSize = 0; - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { remainingSize += fileInfo->GetRemainingSize(); successArticles += fileInfo->GetSuccessArticles(); @@ -2332,9 +2332,9 @@ bool DiskState::LoadAllFileStates(DownloadQueue* downloadQueue, Servers* servers { if (g_Options->GetContinuePartial() && !cacheWasActive) { - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (fileInfo->GetId() == id) { @@ -2457,7 +2457,7 @@ bool DiskState::SaveServerInfo(Servers* servers, DiskFile& outfile) debug("Saving server info to disk"); outfile.Print("%i\n", (int)servers->size()); - for (NewsServer* newsServer : *servers) + for (NewsServer* newsServer : servers) { outfile.Print("%s\n", newsServer->GetName()); outfile.Print("%s\n", newsServer->GetHost()); @@ -2551,7 +2551,7 @@ void FindCandidates(NewsServer* newsServer, ServerRefList* refs, ECriteria crite void MatchServers(Servers* servers, ServerRefList* serverRefs) { // Step 1: trying perfect match - for (NewsServer* newsServer : *servers) + for (NewsServer* newsServer : servers) { ServerRefList matchedRefs; matchedRefs.insert(matchedRefs.begin(), serverRefs->begin(), serverRefs->end()); @@ -2570,7 +2570,7 @@ void MatchServers(Servers* servers, ServerRefList* serverRefs) } // Step 2: matching host, port, username and server-name - for (NewsServer* newsServer : *servers) + for (NewsServer* newsServer : servers) { if (!newsServer->GetStateId()) { @@ -2655,7 +2655,7 @@ bool DiskState::LoadServerInfo(Servers* servers, DiskFile& infile, int formatVer } debug("******** MATCHING NEWS-SERVERS **********"); - for (NewsServer* newsServer : *servers) + for (NewsServer* newsServer : servers) { *perfectMatch = *perfectMatch && newsServer->GetStateId(); debug("Server %i -> %i", newsServer->GetId(), newsServer->GetStateId()); @@ -2683,7 +2683,7 @@ bool DiskState::SaveVolumeStat(ServerVolumes* serverVolumes, DiskFile& outfile) debug("Saving volume stats to disk"); outfile.Print("%i\n", (int)serverVolumes->size()); - for (ServerVolume& serverVolume : *serverVolumes) + for (ServerVolume& serverVolume : serverVolumes) { outfile.Print("%i,%i,%i\n", serverVolume.GetFirstDay(), (int)serverVolume.GetDataTime(), (int)serverVolume.GetCustomTime()); @@ -2726,7 +2726,7 @@ bool DiskState::LoadVolumeStat(Servers* servers, ServerVolumes* serverVolumes, D } else { - for (NewsServer* newsServer : *servers) + for (NewsServer* newsServer : servers) { if (newsServer->GetStateId() == i) { diff --git a/daemon/queue/DownloadInfo.cpp b/daemon/queue/DownloadInfo.cpp index 887e11dd..dea505bd 100644 --- a/daemon/queue/DownloadInfo.cpp +++ b/daemon/queue/DownloadInfo.cpp @@ -76,7 +76,7 @@ void NzbParameterList::SetParameter(const char* name, const char* value) NzbParameter* NzbParameterList::Find(const char* name, bool caseSensitive) { - for (NzbParameter& parameter : *this) + for (NzbParameter& parameter : this) { if ((caseSensitive && !strcmp(parameter.GetName(), name)) || (!caseSensitive && !strcasecmp(parameter.GetName(), name))) @@ -90,7 +90,7 @@ NzbParameter* NzbParameterList::Find(const char* name, bool caseSensitive) void NzbParameterList::CopyFrom(NzbParameterList* sourceParameters) { - for (NzbParameter& parameter : *sourceParameters) + for (NzbParameter& parameter : sourceParameters) { SetParameter(parameter.GetName(), parameter.GetValue()); } @@ -101,7 +101,7 @@ ScriptStatus::EStatus ScriptStatusList::CalcTotalStatus() { ScriptStatus::EStatus status = ScriptStatus::srNone; - for (ScriptStatus& scriptStatus : *this) + for (ScriptStatus& scriptStatus : this) { // Failure-Status overrides Success-Status if ((scriptStatus.GetStatus() == ScriptStatus::srSuccess && status == ScriptStatus::srNone) || @@ -118,7 +118,7 @@ ScriptStatus::EStatus ScriptStatusList::CalcTotalStatus() void ServerStatList::StatOp(int serverId, int successArticles, int failedArticles, EStatOperation statOperation) { ServerStat* serverStat = nullptr; - for (ServerStat& serverStat1 : *this) + for (ServerStat& serverStat1 : this) { if (serverStat1.GetServerId() == serverId) { @@ -154,7 +154,7 @@ void ServerStatList::StatOp(int serverId, int successArticles, int failedArticle void ServerStatList::ListOp(ServerStatList* serverStats, EStatOperation statOperation) { - for (ServerStat& serverStat : *serverStats) + for (ServerStat& serverStat : serverStats) { StatOp(serverStat.GetServerId(), serverStat.GetSuccessArticles(), serverStat.GetFailedArticles(), statOperation); } @@ -536,7 +536,7 @@ void NzbInfo::CopyFileList(NzbInfo* srcNzbInfo) { m_fileList.Clear(); - for (FileInfo* fileInfo : *srcNzbInfo->GetFileList()) + for (FileInfo* fileInfo : srcNzbInfo->GetFileList()) { fileInfo->SetNzbInfo(this); m_fileList.push_back(fileInfo); @@ -771,7 +771,7 @@ NzbList::~NzbList() void NzbList::Clear() { - for (NzbInfo* nzbInfo : *this) + for (NzbInfo* nzbInfo : this) { delete nzbInfo; } @@ -801,7 +801,7 @@ void NzbList::Remove(NzbInfo* nzbInfo) NzbInfo* NzbList::Find(int id) { - for (NzbInfo* nzbInfo : *this) + for (NzbInfo* nzbInfo : this) { if (nzbInfo->GetId() == id) { @@ -970,7 +970,7 @@ FileList::~FileList() void FileList::Clear() { - for (FileInfo* fileInfo : *this) + for (FileInfo* fileInfo : this) { delete fileInfo; } @@ -1105,7 +1105,7 @@ const char* HistoryInfo::GetName() HistoryList::~HistoryList() { - for (HistoryInfo* historyInfo : *this) + for (HistoryInfo* historyInfo : this) { delete historyInfo; } @@ -1113,7 +1113,7 @@ HistoryList::~HistoryList() HistoryInfo* HistoryList::Find(int id) { - for (HistoryInfo* historyInfo : *this) + for (HistoryInfo* historyInfo : this) { if (historyInfo->GetId() == id) { @@ -1143,7 +1143,7 @@ void DownloadQueue::CalcRemainingSize(int64* remaining, int64* remainingForced) for (NzbInfo* nzbInfo : m_queue) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (!fileInfo->GetPaused() && !fileInfo->GetDeleted()) { diff --git a/daemon/queue/DupeCoordinator.cpp b/daemon/queue/DupeCoordinator.cpp index 0eb8dbe3..c3f3e7b7 100644 --- a/daemon/queue/DupeCoordinator.cpp +++ b/daemon/queue/DupeCoordinator.cpp @@ -58,7 +58,7 @@ void DupeCoordinator::NzbFound(DownloadQueue* downloadQueue, NzbInfo* nzbInfo) debug("Checking duplicates for %s", nzbInfo->GetName()); // find duplicates in download queue with exactly same content - for (NzbInfo* queuedNzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* queuedNzbInfo : downloadQueue->GetQueue()) { bool sameContent = (nzbInfo->GetFullContentHash() > 0 && nzbInfo->GetFullContentHash() == queuedNzbInfo->GetFullContentHash()) || @@ -102,7 +102,7 @@ void DupeCoordinator::NzbFound(DownloadQueue* downloadQueue, NzbInfo* nzbInfo) // take these properties from this item if (Util::EmptyStr(nzbInfo->GetDupeKey()) && nzbInfo->GetDupeScore() == 0) { - for (NzbInfo* queuedNzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* queuedNzbInfo : downloadQueue->GetQueue()) { if (!strcmp(queuedNzbInfo->GetName(), nzbInfo->GetName()) && (!Util::EmptyStr(queuedNzbInfo->GetDupeKey()) || queuedNzbInfo->GetDupeScore() != 0)) @@ -117,7 +117,7 @@ void DupeCoordinator::NzbFound(DownloadQueue* downloadQueue, NzbInfo* nzbInfo) } if (Util::EmptyStr(nzbInfo->GetDupeKey()) && nzbInfo->GetDupeScore() == 0) { - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() == HistoryInfo::hkNzb && !strcmp(historyInfo->GetNzbInfo()->GetName(), nzbInfo->GetName()) && @@ -152,7 +152,7 @@ void DupeCoordinator::NzbFound(DownloadQueue* downloadQueue, NzbInfo* nzbInfo) // find duplicates in history having exactly same content // also: nzb-files having duplicates marked as good are skipped // also (only in score mode): nzb-files having success-duplicates in dup-history but not having duplicates in recent history are skipped - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() == HistoryInfo::hkNzb && ((nzbInfo->GetFullContentHash() > 0 && @@ -209,7 +209,7 @@ void DupeCoordinator::NzbFound(DownloadQueue* downloadQueue, NzbInfo* nzbInfo) if (!sameContent && !good && nzbInfo->GetDupeMode() == dmScore) { // nzb-files having success-duplicates in recent history (with different content) are added to history for backup - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() == HistoryInfo::hkNzb && historyInfo->GetNzbInfo()->GetDupeMode() != dmForce && @@ -322,7 +322,7 @@ void DupeCoordinator::ReturnBestDupe(DownloadQueue* downloadQueue, NzbInfo* nzbI // check if history (recent or dup) has other success-duplicates or good-duplicates bool dupeFound = false; int historyScore = 0; - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { bool goodDupe = false; @@ -363,7 +363,7 @@ void DupeCoordinator::ReturnBestDupe(DownloadQueue* downloadQueue, NzbInfo* nzbI // check if duplicates exist in download queue bool queueDupe = false; int queueScore = 0; - for (NzbInfo* queuedNzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* queuedNzbInfo : downloadQueue->GetQueue()) { if (queuedNzbInfo != nzbInfo && queuedNzbInfo->GetKind() == NzbInfo::nkNzb && @@ -379,7 +379,7 @@ void DupeCoordinator::ReturnBestDupe(DownloadQueue* downloadQueue, NzbInfo* nzbI // find dupe-backup with highest score, whose score is also higher than other // success-duplicates and higher than already queued items HistoryInfo* historyDupe = nullptr; - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() == HistoryInfo::hkNzb && historyInfo->GetNzbInfo()->GetDupeMode() != dmForce && @@ -498,7 +498,7 @@ DupeCoordinator::EDupeStatus DupeCoordinator::GetDupeStatus(DownloadQueue* downl EDupeStatus statuses = dsNone; // find duplicates in download queue - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { if (SameNameOrKey(name, dupeKey, nzbInfo->GetName(), nzbInfo->GetDupeKey())) { @@ -514,7 +514,7 @@ DupeCoordinator::EDupeStatus DupeCoordinator::GetDupeStatus(DownloadQueue* downl } // find duplicates in history - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() == HistoryInfo::hkNzb && SameNameOrKey(name, dupeKey, historyInfo->GetNzbInfo()->GetName(), historyInfo->GetNzbInfo()->GetDupeKey())) @@ -561,7 +561,7 @@ void DupeCoordinator::ListHistoryDupes(DownloadQueue* downloadQueue, NzbInfo* nz } // find duplicates in history - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() == HistoryInfo::hkNzb && historyInfo->GetNzbInfo()->GetDupeMode() != dmForce && diff --git a/daemon/queue/HistoryCoordinator.cpp b/daemon/queue/HistoryCoordinator.cpp index 8c6c8697..722dc0df 100644 --- a/daemon/queue/HistoryCoordinator.cpp +++ b/daemon/queue/HistoryCoordinator.cpp @@ -379,7 +379,7 @@ void HistoryCoordinator::HistoryReturn(DownloadQueue* downloadQueue, HistoryList // unpark files bool unparked = false; - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { detail("Unpark file %s", fileInfo->GetFilename()); unparked = true; @@ -484,7 +484,7 @@ void HistoryCoordinator::HistoryRedownload(DownloadQueue* downloadQueue, History info("Returning %s from history back to queue", nzbInfo->GetName()); - for (FileInfo* fileInfo : *nzbFile->GetNzbInfo()->GetFileList()) + for (FileInfo* fileInfo : nzbFile->GetNzbInfo()->GetFileList()) { fileInfo->SetPaused(paused); } diff --git a/daemon/queue/NzbFile.cpp b/daemon/queue/NzbFile.cpp index 1ff4d896..a435e15e 100644 --- a/daemon/queue/NzbFile.cpp +++ b/daemon/queue/NzbFile.cpp @@ -294,14 +294,14 @@ bool NzbFile::HasDuplicateFilenames() */ void NzbFile::BuildFilenames() { - for (FileInfo* fileInfo : *m_nzbInfo->GetFileList()) + for (FileInfo* fileInfo : m_nzbInfo->GetFileList()) { ParseSubject(fileInfo, true); } if (HasDuplicateFilenames()) { - for (FileInfo* fileInfo : *m_nzbInfo->GetFileList()) + for (FileInfo* fileInfo : m_nzbInfo->GetFileList()) { ParseSubject(fileInfo, false); } @@ -310,7 +310,7 @@ void NzbFile::BuildFilenames() if (HasDuplicateFilenames()) { m_nzbInfo->SetManyDupeFiles(true); - for (FileInfo* fileInfo : *m_nzbInfo->GetFileList()) + for (FileInfo* fileInfo : m_nzbInfo->GetFileList()) { fileInfo->SetFilename(fileInfo->GetSubject()); } @@ -326,7 +326,7 @@ void NzbFile::CalcHashes() { TempFileList fileList; - for (FileInfo* fileInfo : *m_nzbInfo->GetFileList()) + for (FileInfo* fileInfo : m_nzbInfo->GetFileList()) { fileList.push_back(fileInfo); } @@ -369,7 +369,7 @@ void NzbFile::ProcessFiles() { BuildFilenames(); - for (FileInfo* fileInfo : *m_nzbInfo->GetFileList()) + for (FileInfo* fileInfo : m_nzbInfo->GetFileList()) { fileInfo->MakeValidFilename(); @@ -400,7 +400,7 @@ void NzbFile::ProcessFiles() if (g_Options->GetSaveQueue() && g_Options->GetServerMode()) { - for (FileInfo* fileInfo : *m_nzbInfo->GetFileList()) + for (FileInfo* fileInfo : m_nzbInfo->GetFileList()) { g_DiskState->SaveFile(fileInfo); fileInfo->ClearArticles(); diff --git a/daemon/queue/QueueCoordinator.cpp b/daemon/queue/QueueCoordinator.cpp index c7ac326a..311841b6 100644 --- a/daemon/queue/QueueCoordinator.cpp +++ b/daemon/queue/QueueCoordinator.cpp @@ -143,11 +143,11 @@ void QueueCoordinator::Load() // re-save file states into diskstate to update server ids if (g_Options->GetServerMode() && g_Options->GetSaveQueue()) { - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { if (g_Options->GetContinuePartial()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (!fileInfo->GetArticles()->empty()) { @@ -156,7 +156,7 @@ void QueueCoordinator::Load() } } - for (CompletedFile& completedFile : *nzbInfo->GetCompletedFiles()) + for (CompletedFile& completedFile : nzbInfo->GetCompletedFiles()) { if (completedFile.GetStatus() != CompletedFile::cfSuccess && completedFile.GetId() > 0) { @@ -300,7 +300,7 @@ void QueueCoordinator::AdjustDownloadsLimit() int downloadsLimit = 2; // allow one thread per 0-level (main) and 1-level (backup) server connection - for (NewsServer* newsServer : *g_ServerPool->GetServers()) + for (NewsServer* newsServer : g_ServerPool->GetServers()) { if ((newsServer->GetNormLevel() == 0 || newsServer->GetNormLevel() == 1) && newsServer->GetActive()) { @@ -410,12 +410,12 @@ void QueueCoordinator::CheckDupeFileInfos(NzbInfo* nzbInfo) FileList dupeList(true); int index1 = 0; - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { index1++; bool dupe = false; int index2 = 0; - for (FileInfo* fileInfo2 : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo2 : nzbInfo->GetFileList()) { index2++; if (fileInfo != fileInfo2 && @@ -486,9 +486,9 @@ bool QueueCoordinator::GetNextArticle(DownloadQueue* downloadQueue, FileInfo* &f int num = 0; int fileNum = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { - for (FileInfo* fileInfo1 : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo1 : nzbInfo->GetFileList()) { if ((!checkedFiles || !checkedFiles[num]) && !fileInfo1->GetPaused() && !fileInfo1->GetDeleted() && @@ -519,7 +519,7 @@ bool QueueCoordinator::GetNextArticle(DownloadQueue* downloadQueue, FileInfo* &f } // check if the file has any articles left for download - for (ArticleInfo* article : *fileInfo->GetArticles()) + for (ArticleInfo* article : fileInfo->GetArticles()) { if (article->GetStatus() == ArticleInfo::aiUndefined) { @@ -535,7 +535,7 @@ bool QueueCoordinator::GetNextArticle(DownloadQueue* downloadQueue, FileInfo* &f if (!checkedFiles) { int totalFileCount = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { totalFileCount += nzbInfo->GetFileList()->size(); } @@ -801,7 +801,7 @@ void QueueCoordinator::DiscardDiskFile(FileInfo* fileInfo) if (!g_Options->GetDirectWrite()) { - for (ArticleInfo* pa : *fileInfo->GetArticles()) + for (ArticleInfo* pa : fileInfo->GetArticles()) { if (pa->GetResultFilename()) { @@ -825,9 +825,9 @@ void QueueCoordinator::SavePartialState() DownloadQueue* downloadQueue = DownloadQueue::Lock(); - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (fileInfo->GetPartialChanged()) { @@ -1042,7 +1042,7 @@ bool QueueCoordinator::MergeQueueEntries(DownloadQueue* downloadQueue, NzbInfo* SetQueueEntryCategory(downloadQueue, srcNzbInfo, destNzbInfo->GetCategory()); // reattach file items to new NZBInfo-object - for (FileInfo* fileInfo : *srcNzbInfo->GetFileList()) + for (FileInfo* fileInfo : srcNzbInfo->GetFileList()) { fileInfo->SetNzbInfo(destNzbInfo); destNzbInfo->GetFileList()->push_back(fileInfo); @@ -1090,7 +1090,7 @@ bool QueueCoordinator::MergeQueueEntries(DownloadQueue* downloadQueue, NzbInfo* destNzbInfo->GetDownloadStartTime() : srcNzbInfo->GetDownloadStartTime()); // reattach completed file items to new NZBInfo-object - for (CompletedFile& completedFile : *srcNzbInfo->GetCompletedFiles()) + for (CompletedFile& completedFile : srcNzbInfo->GetCompletedFiles()) { destNzbInfo->GetCompletedFiles()->push_back(std::move(completedFile)); } @@ -1122,7 +1122,7 @@ bool QueueCoordinator::SplitQueueEntries(DownloadQueue* downloadQueue, FileList* NzbInfo* srcNzbInfo = nullptr; - for (FileInfo* fileInfo : *fileList) + for (FileInfo* fileInfo : fileList) { if (fileInfo->GetActiveDownloads() > 0 || fileInfo->GetCompletedArticles() > 0) { @@ -1156,7 +1156,7 @@ bool QueueCoordinator::SplitQueueEntries(DownloadQueue* downloadQueue, FileList* srcNzbInfo->SetFullContentHash(0); srcNzbInfo->SetFilteredContentHash(0); - for (FileInfo* fileInfo : *fileList) + for (FileInfo* fileInfo : fileList) { DownloadQueue::Aspect aspect = { DownloadQueue::eaFileDeleted, downloadQueue, fileInfo->GetNzbInfo(), fileInfo }; downloadQueue->Notify(&aspect); diff --git a/daemon/queue/QueueEditor.cpp b/daemon/queue/QueueEditor.cpp index 4f482175..473c1720 100644 --- a/daemon/queue/QueueEditor.cpp +++ b/daemon/queue/QueueEditor.cpp @@ -147,7 +147,7 @@ bool GroupSorter::operator()(NzbInfo* nzbInfo1, NzbInfo* nzbInfo2) const bool sortItem1 = m_sortItemList->empty(); bool sortItem2 = m_sortItemList->empty(); - for (QueueEditor::EditItem* item : *m_sortItemList) + for (QueueEditor::EditItem* item : m_sortItemList) { sortItem1 |= item->m_nzbInfo == nzbInfo1; sortItem2 |= item->m_nzbInfo == nzbInfo2; @@ -206,7 +206,7 @@ void GroupSorter::AlignSelectedGroups() NzbInfo* nzbInfo = m_nzbList->at(num); bool selected = false; - for (QueueEditor::EditItem* item : *m_sortItemList) + for (QueueEditor::EditItem* item : m_sortItemList) { if (item->m_nzbInfo == nzbInfo) { @@ -253,9 +253,9 @@ QueueEditor::~QueueEditor() FileInfo* QueueEditor::FindFileInfo(int id) { - for (NzbInfo* nzbInfo : *m_downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : m_downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (fileInfo->GetId() == id) { @@ -291,7 +291,7 @@ void QueueEditor::DeleteEntry(FileInfo* fileInfo) void QueueEditor::MoveEntry(FileInfo* fileInfo, int offset) { int entry = 0; - for (FileInfo* fileInfo2 : *fileInfo->GetNzbInfo()->GetFileList()) + for (FileInfo* fileInfo2 : fileInfo->GetNzbInfo()->GetFileList()) { if (fileInfo2 == fileInfo) { @@ -325,7 +325,7 @@ void QueueEditor::MoveEntry(FileInfo* fileInfo, int offset) void QueueEditor::MoveGroup(NzbInfo* nzbInfo, int offset) { int entry = 0; - for (NzbInfo* nzbInfo2 : *m_downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo2 : m_downloadQueue->GetQueue()) { if (nzbInfo2 == nzbInfo) { @@ -425,7 +425,7 @@ bool QueueEditor::InternEditList(ItemList* itemList, break; default: - for (EditItem* item : *itemList) + for (EditItem* item : itemList) { switch (action) { @@ -524,7 +524,7 @@ void QueueEditor::PrepareList(ItemList* itemList, IdList* idList, (action == DownloadQueue::eaFileMoveOffset || action == DownloadQueue::eaFileMoveTop || action == DownloadQueue::eaFileMoveBottom)) { // add IDs to list in order they currently have in download queue - for (NzbInfo* nzbInfo : *m_downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : m_downloadQueue->GetQueue()) { int nrEntries = (int)nzbInfo->GetFileList()->size(); int lastDestPos = -1; @@ -637,9 +637,9 @@ void QueueEditor::PrepareList(ItemList* itemList, IdList* idList, // check ID range int maxId = 0; int minId = MAX_ID; - for (NzbInfo* nzbInfo : *m_downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : m_downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { int ID = fileInfo->GetId(); if (ID > maxId) @@ -671,7 +671,7 @@ void QueueEditor::PrepareList(ItemList* itemList, IdList* idList, // check ID range int maxId = 0; int minId = MAX_ID; - for (NzbInfo* nzbInfo : *m_downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : m_downloadQueue->GetQueue()) { int ID = nzbInfo->GetId(); if (ID > maxId) @@ -689,7 +689,7 @@ void QueueEditor::PrepareList(ItemList* itemList, IdList* idList, { if (minId <= id && id <= maxId) { - for (NzbInfo* nzbInfo : *m_downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : m_downloadQueue->GetQueue()) { if (id == nzbInfo->GetId()) { @@ -712,7 +712,7 @@ bool QueueEditor::BuildIdListFromNameList(IdList* idList, NameList* nameList, Do std::set uniqueIds; - for (CString& name : *nameList) + for (CString& name : nameList) { RegEx *regEx = nullptr; if (matchMode == DownloadQueue::mmRegEx) @@ -727,9 +727,9 @@ bool QueueEditor::BuildIdListFromNameList(IdList* idList, NameList* nameList, Do bool found = false; - for (NzbInfo* nzbInfo : *m_downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : m_downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (action < DownloadQueue::eaGroupMoveOffset) { @@ -777,7 +777,7 @@ bool QueueEditor::EditGroup(NzbInfo* nzbInfo, DownloadQueue::EEditAction action, int id = nzbInfo->GetId(); // collecting files belonging to group - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { itemList.push_back(new EditItem(fileInfo, nullptr, 0)); allPaused &= fileInfo->GetPaused(); @@ -886,7 +886,7 @@ void QueueEditor::PausePars(FileList* fileList, bool extraParsOnly) FileList Pars, Vols; - for (FileInfo* fileInfo : *fileList) + for (FileInfo* fileInfo : fileList) { BString<1024> loFileName = fileInfo->GetFilename(); for (char* p = loFileName; *p; p++) *p = tolower(*p); // convert string to lowercase @@ -1055,7 +1055,7 @@ bool QueueEditor::CanCleanupDisk(NzbInfo* nzbInfo) return true; } - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { BString<1024> loFileName = fileInfo->GetFilename(); for (char* p = loFileName; *p; p++) *p = tolower(*p); // convert string to lowercase @@ -1081,7 +1081,7 @@ bool QueueEditor::MergeGroups(ItemList* itemList) EditItem* destItem = itemList->front(); - for (EditItem* item : *itemList) + for (EditItem* item : itemList) { if (item->m_nzbInfo != destItem->m_nzbInfo) { @@ -1107,7 +1107,7 @@ bool QueueEditor::SplitGroup(ItemList* itemList, const char* name) FileList fileList(false); - for (EditItem* item : *itemList) + for (EditItem* item : itemList) { fileList.push_back(item->m_fileInfo); delete item; @@ -1137,7 +1137,7 @@ void QueueEditor::ReorderFiles(ItemList* itemList) uint32 insertPos = 0; // now can reorder - for (EditItem* item : *itemList) + for (EditItem* item : itemList) { FileInfo* fileInfo = item->m_fileInfo; diff --git a/daemon/queue/Scanner.cpp b/daemon/queue/Scanner.cpp index a7f5addc..473f4ffb 100644 --- a/daemon/queue/Scanner.cpp +++ b/daemon/queue/Scanner.cpp @@ -392,7 +392,7 @@ void Scanner::InitPPParameters(const char* category, NzbParameterList* parameter if (reset) { - for (ScriptConfig::Script& script : *g_ScriptConfig->GetScripts()) + for (ScriptConfig::Script& script : g_ScriptConfig->GetScripts()) { parameters->SetParameter(BString<1024>("%s:", script.GetName()), nullptr); } @@ -462,7 +462,7 @@ bool Scanner::AddFileToQueue(const char* filename, const char* nzbName, const ch nzbInfo->GetParameters()->CopyFrom(parameters); - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { fileInfo->SetPaused(addPaused); } diff --git a/daemon/queue/UrlCoordinator.cpp b/daemon/queue/UrlCoordinator.cpp index 56348cb9..e86e683b 100644 --- a/daemon/queue/UrlCoordinator.cpp +++ b/daemon/queue/UrlCoordinator.cpp @@ -248,7 +248,7 @@ NzbInfo* UrlCoordinator::GetNextUrl(DownloadQueue* downloadQueue) NzbInfo* nzbInfo = nullptr; - for (NzbInfo* nzbInfo1 : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo1 : downloadQueue->GetQueue()) { if (nzbInfo1->GetKind() == NzbInfo::nkUrl && nzbInfo1->GetUrlStatus() == NzbInfo::lsNone && diff --git a/daemon/remote/BinRpc.cpp b/daemon/remote/BinRpc.cpp index 22686fee..282044bc 100644 --- a/daemon/remote/BinRpc.cpp +++ b/daemon/remote/BinRpc.cpp @@ -504,7 +504,7 @@ void ListBinCommand::Execute() int nrNzbEntries = downloadQueue->GetQueue()->size(); int nrPPPEntries = 0; bufsize += nrNzbEntries * sizeof(SNzbListResponseNzbEntry); - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { bufsize += strlen(nzbInfo->GetFilename()) + 1; bufsize += strlen(nzbInfo->GetName()) + 1; @@ -515,7 +515,7 @@ void ListBinCommand::Execute() bufsize += bufsize % 4 > 0 ? 4 - bufsize % 4 : 0; // calculate required buffer size for pp-parameters - for (NzbParameter& nzbParameter : *nzbInfo->GetParameters()) + for (NzbParameter& nzbParameter : nzbInfo->GetParameters()) { bufsize += sizeof(SNzbListResponsePPPEntry); bufsize += strlen(nzbParameter.GetName()) + 1; @@ -528,9 +528,9 @@ void ListBinCommand::Execute() // calculate required buffer size for files int nrFileEntries = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { nrFileEntries++; bufsize += sizeof(SNzbListResponseFileEntry); @@ -545,7 +545,7 @@ void ListBinCommand::Execute() char* bufptr = buf; // write nzb entries - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { SNzbListResponseNzbEntry* listAnswer = (SNzbListResponseNzbEntry*) bufptr; @@ -593,10 +593,10 @@ void ListBinCommand::Execute() // write ppp entries int nzbIndex = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { nzbIndex++; - for (NzbParameter& nzbParameter : *nzbInfo->GetParameters()) + for (NzbParameter& nzbParameter : nzbInfo->GetParameters()) { SNzbListResponsePPPEntry* listAnswer = (SNzbListResponsePPPEntry*) bufptr; listAnswer->m_nzbIndex = htonl(nzbIndex); @@ -618,9 +618,9 @@ void ListBinCommand::Execute() } // write file entries - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { uint32 sizeHi, sizeLo; SNzbListResponseFileEntry* listAnswer = (SNzbListResponseFileEntry*) bufptr; @@ -684,7 +684,7 @@ void ListBinCommand::Execute() { DownloadQueue *downloadQueue = DownloadQueue::Lock(); int postJobCount = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { postJobCount += nzbInfo->GetPostInfo() ? 1 : 0; } @@ -928,7 +928,7 @@ void PostQueueBinCommand::Execute() // calculate required buffer size int NrEntries = 0; - for (NzbInfo* nzbInfo : *nzbList) + for (NzbInfo* nzbInfo : nzbList) { PostInfo* postInfo = nzbInfo->GetPostInfo(); if (!postInfo) @@ -950,7 +950,7 @@ void PostQueueBinCommand::Execute() buf = (char*) malloc(bufsize); char* bufptr = buf; - for (NzbInfo* nzbInfo : *nzbList) + for (NzbInfo* nzbInfo : nzbList) { PostInfo* postInfo = nzbInfo->GetPostInfo(); if (!postInfo) @@ -1085,7 +1085,7 @@ void HistoryBinCommand::Execute() // calculate required buffer size for nzbs int nrEntries = 0; - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() != HistoryInfo::hkDup || showHidden) { @@ -1093,7 +1093,7 @@ void HistoryBinCommand::Execute() } } bufsize += nrEntries * sizeof(SNzbHistoryResponseEntry); - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() != HistoryInfo::hkDup || showHidden) { @@ -1107,7 +1107,7 @@ void HistoryBinCommand::Execute() char* bufptr = buf; // write nzb entries - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() != HistoryInfo::hkDup || showHidden) { diff --git a/daemon/remote/RemoteClient.cpp b/daemon/remote/RemoteClient.cpp index 5e40c931..7911e23e 100644 --- a/daemon/remote/RemoteClient.cpp +++ b/daemon/remote/RemoteClient.cpp @@ -379,9 +379,9 @@ bool RemoteClient::RequestServerList(bool files, bool groups, const char* patter int matches = 0; int nrFileEntries = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { nrFileEntries++; @@ -463,7 +463,7 @@ bool RemoteClient::RequestServerList(bool files, bool groups, const char* patter int matches = 0; int nrFileEntries = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { nrFileEntries += nzbInfo->GetFileList()->size(); @@ -498,7 +498,7 @@ bool RemoteClient::RequestServerList(bool files, bool groups, const char* patter } BString<1024> parameters; - for (NzbParameter& nzbParameter : *nzbInfo->GetParameters()) + for (NzbParameter& nzbParameter : nzbInfo->GetParameters()) { parameters.Append(parameters.Empty() ? " (" : ", "); parameters.AppendFmt("%s=%s", nzbParameter.GetName(), nzbParameter.GetValue()); @@ -811,7 +811,7 @@ bool RemoteClient::RequestServerEditQueue(DownloadQueue::EEditAction action, int int nameLength = 0; if (nameList && nameList->size() > 0) { - for (CString& name : *nameList) + for (CString& name : nameList) { nameLength += strlen(name) + 1; nameCount++; @@ -854,7 +854,7 @@ bool RemoteClient::RequestServerEditQueue(DownloadQueue::EEditAction action, int if (nameCount > 0) { char *names = trailingData + textLen + idLength; - for (CString& name : *nameList) + for (CString& name : nameList) { int len = strlen(name); strncpy(names, name, len + 1); diff --git a/daemon/remote/XmlRpc.cpp b/daemon/remote/XmlRpc.cpp index 8321e065..da070a07 100644 --- a/daemon/remote/XmlRpc.cpp +++ b/daemon/remote/XmlRpc.cpp @@ -1309,7 +1309,7 @@ void StatusXmlCommand::Execute() DownloadQueue* downloadQueue = DownloadQueue::Lock(); int postJobCount = 0; int urlCount = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { postJobCount += nzbInfo->GetPostInfo() ? 1 : 0; urlCount += nzbInfo->GetKind() == NzbInfo::nkUrl ? 1 : 0; @@ -1367,7 +1367,7 @@ void StatusXmlCommand::Execute() BoolToStr(feedActive), queuedScripts); int index = 0; - for (NewsServer* server : *g_ServerPool->GetServers()) + for (NewsServer* server : g_ServerPool->GetServers()) { AppendCondResponse(",\n", IsJson() && index++ > 0); AppendFmtResponse(IsJson() ? JSON_NEWSSERVER_ITEM : XML_NEWSSERVER_ITEM, @@ -1533,9 +1533,9 @@ void ListFilesXmlCommand::Execute() int index = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { - for (FileInfo* fileInfo : *nzbInfo->GetFileList()) + for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if ((nzbId > 0 && nzbId == fileInfo->GetNzbInfo()->GetId()) || (nzbId == 0 && (idStart == 0 || (idStart <= fileInfo->GetId() && fileInfo->GetId() <= idEnd)))) @@ -1763,7 +1763,7 @@ void NzbInfoXmlCommand::AppendNzbInfoFields(NzbInfo* nzbInfo) // Post-processing parameters int paramIndex = 0; - for (NzbParameter& parameter : *nzbInfo->GetParameters()) + for (NzbParameter& parameter : nzbInfo->GetParameters()) { AppendCondResponse(",\n", IsJson() && paramIndex++ > 0); AppendFmtResponse(IsJson() ? JSON_PARAMETER_ITEM : XML_PARAMETER_ITEM, @@ -1774,7 +1774,7 @@ void NzbInfoXmlCommand::AppendNzbInfoFields(NzbInfo* nzbInfo) // Script statuses int scriptIndex = 0; - for (ScriptStatus& scriptStatus : *nzbInfo->GetScriptStatuses()) + for (ScriptStatus& scriptStatus : nzbInfo->GetScriptStatuses()) { AppendCondResponse(",\n", IsJson() && scriptIndex++ > 0); AppendFmtResponse(IsJson() ? JSON_SCRIPT_ITEM : XML_SCRIPT_ITEM, @@ -1785,7 +1785,7 @@ void NzbInfoXmlCommand::AppendNzbInfoFields(NzbInfo* nzbInfo) // Server stats int statIndex = 0; - for (ServerStat& serverStat : *nzbInfo->GetCurrentServerStats()) + for (ServerStat& serverStat : nzbInfo->GetCurrentServerStats()) { AppendCondResponse(",\n", IsJson() && statIndex++ > 0); AppendFmtResponse(IsJson() ? JSON_STAT_ITEM : XML_STAT_ITEM, @@ -1949,7 +1949,7 @@ void ListGroupsXmlCommand::Execute() DownloadQueue* downloadQueue = DownloadQueue::Lock(); - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { uint32 remainingSizeLo, remainingSizeHi, remainingSizeMB; uint32 pausedSizeLo, pausedSizeHi, pausedSizeMB; @@ -2331,7 +2331,7 @@ void PostQueueXmlCommand::Execute() int index = 0; - for (NzbInfo* nzbInfo : *nzbList) + for (NzbInfo* nzbInfo : nzbList) { PostInfo* postInfo = nzbInfo->GetPostInfo(); if (!postInfo) @@ -2503,7 +2503,7 @@ void HistoryXmlCommand::Execute() int index = 0; - for (HistoryInfo* historyInfo : *downloadQueue->GetHistory()) + for (HistoryInfo* historyInfo : downloadQueue->GetHistory()) { if (historyInfo->GetKind() == HistoryInfo::hkDup && !dup) { @@ -2603,7 +2603,7 @@ void UrlQueueXmlCommand::Execute() int index = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { if (nzbInfo->GetKind() == NzbInfo::nkUrl) { @@ -2640,7 +2640,7 @@ void ConfigXmlCommand::Execute() Options::OptEntries* optEntries = g_Options->LockOptEntries(); - for (Options::OptEntry& optEntry : *optEntries) + for (Options::OptEntry& optEntry : optEntries) { CString xmlValue = EncodeStr(m_userAccess == XmlRpcProcessor::uaRestricted && optEntry.Restricted() ? "***" : optEntry.GetValue()); @@ -2770,7 +2770,7 @@ void ConfigTemplatesXmlCommand::Execute() int index = 0; - for (ScriptConfig::ConfigTemplate& configTemplate : *configTemplates) + for (ScriptConfig::ConfigTemplate& configTemplate : configTemplates) { AppendCondResponse(",\n", IsJson() && index++ > 0); AppendFmtResponse(IsJson() ? JSON_CONFIG_ITEM : XML_CONFIG_ITEM, @@ -2920,7 +2920,7 @@ void ViewFeedXmlCommand::Execute() AppendResponse(IsJson() ? "[\n" : "\n"); int index = 0; - for (FeedItemInfo& feedItemInfo : *feedItemInfos) + for (FeedItemInfo& feedItemInfo : feedItemInfos) { if (includeNonMatching || feedItemInfo.GetMatchStatus() == FeedItemInfo::msAccepted) { @@ -2988,7 +2988,7 @@ void EditServerXmlCommand::Execute() return; } - for (NewsServer* server : *g_ServerPool->GetServers()) + for (NewsServer* server : g_ServerPool->GetServers()) { if (server->GetId() == id) { @@ -3218,7 +3218,7 @@ void ServerVolumesXmlCommand::Execute() int index = 0; - for (ServerVolume& serverVolume : *serverVolumes) + for (ServerVolume& serverVolume : serverVolumes) { uint32 totalSizeHi, totalSizeLo, totalSizeMB; Util::SplitInt64(serverVolume.GetTotalBytes(), &totalSizeHi, &totalSizeLo); @@ -3295,7 +3295,7 @@ void ResetServerVolumeXmlCommand::Execute() bool ok = false; ServerVolumes* serverVolumes = g_StatMeter->LockServerVolumes(); int index = 0; - for (ServerVolume& serverVolume : *serverVolumes) + for (ServerVolume& serverVolume : serverVolumes) { if (index == serverId || serverId == -1) { diff --git a/daemon/util/Script.cpp b/daemon/util/Script.cpp index 1f1fd98b..77fcf6b8 100644 --- a/daemon/util/Script.cpp +++ b/daemon/util/Script.cpp @@ -231,7 +231,7 @@ void ScriptController::PrepareEnvOptions(const char* stripPrefix) Options::OptEntries* optEntries = g_Options->LockOptEntries(); - for (Options::OptEntry& optEntry : *optEntries) + for (Options::OptEntry& optEntry : optEntries) { if (stripPrefix && !strncmp(optEntry.GetName(), stripPrefix, prefixLen) && (int)strlen(optEntry.GetName()) > prefixLen) diff --git a/daemon/windows/WinConsole.cpp b/daemon/windows/WinConsole.cpp index 248b3694..3fccd1aa 100644 --- a/daemon/windows/WinConsole.cpp +++ b/daemon/windows/WinConsole.cpp @@ -789,7 +789,7 @@ void WinConsole::UpdateTrayIcon() DownloadQueue *downloadQueue = DownloadQueue::Lock(); int postJobCount = 0; int urlCount = 0; - for (NzbInfo* nzbInfo : *downloadQueue->GetQueue()) + for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { postJobCount += nzbInfo->GetPostInfo() ? 1 : 0; urlCount += nzbInfo->GetKind() == NzbInfo::nkUrl ? 1 : 0; @@ -827,7 +827,7 @@ void WinConsole::UpdateTrayIcon() void WinConsole::BuildMenu() { int index = 0; - for (Options::Category& category : *g_Options->GetCategories()) + for (Options::Category& category : g_Options->GetCategories()) { BString<1024> caption("Category %i: %s", index + 1, category.GetName());