diff options
| author | Nils Maier <maierman@web.de> | 2013-08-21 05:06:53 +0200 |
|---|---|---|
| committer | Nils Maier <maierman@web.de> | 2013-08-21 05:56:17 +0200 |
| commit | 8526ceeb452d23d7aa73d01c6cb0fc8ae5e0377b (patch) | |
| tree | 825b4f5d2a0f18331fbbf24773e80ee0b44b50dc /src/DownloadContext.cc | |
| parent | d8f44ef4f6c5ad86b08658ecba41a84b775b6e69 (diff) | |
Convert to autos and ranged loops
Diffstat (limited to 'src/DownloadContext.cc')
| -rw-r--r-- | src/DownloadContext.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/DownloadContext.cc b/src/DownloadContext.cc index fc5b1681..cb945663 100644 --- a/src/DownloadContext.cc +++ b/src/DownloadContext.cc @@ -101,9 +101,8 @@ DownloadContext::findFileEntryByOffset(int64_t offset) const std::shared_ptr<FileEntry> obj(new FileEntry()); obj->setOffset(offset); - std::vector<std::shared_ptr<FileEntry> >::const_iterator i = - std::upper_bound(fileEntries_.begin(), fileEntries_.end(), obj, - DerefLess<std::shared_ptr<FileEntry> >()); + auto i = std::upper_bound(fileEntries_.begin(), fileEntries_.end(), obj, + DerefLess<std::shared_ptr<FileEntry> >()); if(i != fileEntries_.end() && (*i)->getOffset() == offset) { return *i; } else { @@ -216,10 +215,9 @@ const std::string& DownloadContext::getBasePath() const std::shared_ptr<FileEntry> DownloadContext::getFirstRequestedFileEntry() const { - for(std::vector<std::shared_ptr<FileEntry> >::const_iterator i = - fileEntries_.begin(), eoi = fileEntries_.end(); i != eoi; ++i) { - if((*i)->isRequested()) { - return *i; + for (auto& e : fileEntries_) { + if(e->isRequested()) { + return e; } } return nullptr; @@ -228,9 +226,8 @@ DownloadContext::getFirstRequestedFileEntry() const size_t DownloadContext::countRequestedFileEntry() const { size_t numFiles = 0; - for(std::vector<std::shared_ptr<FileEntry> >::const_iterator i = - fileEntries_.begin(), eoi = fileEntries_.end(); i != eoi; ++i) { - if((*i)->isRequested()) { + for (const auto& e: fileEntries_) { + if(e->isRequested()) { ++numFiles; } } |
