diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2017-03-02 22:40:36 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2017-03-02 22:48:40 +0900 |
| commit | 9eff8100ef28ccda14161a35628c51063cf66f66 (patch) | |
| tree | 7af3c8d27cdebc7ea85ebed4d02929147c7574fe /src | |
| parent | 924e115e3e1c49ac7d9eab4389dc627da0bbf9b7 (diff) | |
Refactor
Diffstat (limited to 'src')
| -rw-r--r-- | src/BtFileAllocationEntry.cc | 26 | ||||
| -rw-r--r-- | src/StreamFileAllocationEntry.cc | 24 |
2 files changed, 25 insertions, 25 deletions
diff --git a/src/BtFileAllocationEntry.cc b/src/BtFileAllocationEntry.cc index 3cb1daa7..d173b7ce 100644 --- a/src/BtFileAllocationEntry.cc +++ b/src/BtFileAllocationEntry.cc @@ -60,30 +60,30 @@ BtFileAllocationEntry::~BtFileAllocationEntry() = default; void BtFileAllocationEntry::prepareForNextAction( std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e) { - auto& option = getRequestGroup()->getOption(); + auto rg = getRequestGroup(); + auto& dctx = rg->getDownloadContext(); + auto& ps = rg->getPieceStorage(); + auto diskAdaptor = ps->getDiskAdaptor(); + auto& option = rg->getOption(); - BtSetup().setup(commands, getRequestGroup(), e, option.get()); + BtSetup().setup(commands, rg, e, option.get()); if (option->getAsBool(PREF_ENABLE_MMAP) && option->get(PREF_FILE_ALLOCATION) != V_NONE && - getRequestGroup()->getPieceStorage()->getDiskAdaptor()->size() <= - option->getAsLLInt(PREF_MAX_MMAP_LIMIT)) { - getRequestGroup()->getPieceStorage()->getDiskAdaptor()->enableMmap(); + diskAdaptor->size() <= option->getAsLLInt(PREF_MAX_MMAP_LIMIT)) { + diskAdaptor->enableMmap(); } - if (!getRequestGroup()->downloadFinished()) { + if (!rg->downloadFinished()) { // For DownloadContext::resetDownloadStartTime(), see also // RequestGroup::createInitialCommand() - getRequestGroup()->getDownloadContext()->resetDownloadStartTime(); - const std::vector<std::shared_ptr<FileEntry>>& fileEntries = - getRequestGroup()->getDownloadContext()->getFileEntries(); + dctx->resetDownloadStartTime(); + const auto& fileEntries = dctx->getFileEntries(); if (isUriSuppliedForRequsetFileEntry(std::begin(fileEntries), std::end(fileEntries))) { - getRequestGroup()->createNextCommandWithAdj(commands, e, 0); + rg->createNextCommandWithAdj(commands, e, 0); } } else { #ifdef __MINGW32__ - const std::shared_ptr<DiskAdaptor>& diskAdaptor = - getRequestGroup()->getPieceStorage()->getDiskAdaptor(); if (!diskAdaptor->isReadOnlyEnabled()) { // On Windows, if aria2 opens files with GENERIC_WRITE access // right, some programs cannot open them aria2 is seeding. To @@ -96,7 +96,7 @@ void BtFileAllocationEntry::prepareForNextAction( diskAdaptor->openFile(); } #endif // __MINGW32__ - getRequestGroup()->enableSeedOnly(); + rg->enableSeedOnly(); } } diff --git a/src/StreamFileAllocationEntry.cc b/src/StreamFileAllocationEntry.cc index b455f280..fdb16f60 100644 --- a/src/StreamFileAllocationEntry.cc +++ b/src/StreamFileAllocationEntry.cc @@ -60,28 +60,28 @@ StreamFileAllocationEntry::~StreamFileAllocationEntry() = default; void StreamFileAllocationEntry::prepareForNextAction( std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e) { - auto& option = getRequestGroup()->getOption(); + auto rg = getRequestGroup(); + auto& dctx = rg->getDownloadContext(); + auto& ps = rg->getPieceStorage(); + auto diskAdaptor = ps->getDiskAdaptor(); + auto& option = rg->getOption(); // For DownloadContext::resetDownloadStartTime(), see also // RequestGroup::createInitialCommand() - getRequestGroup()->getDownloadContext()->resetDownloadStartTime(); + dctx->resetDownloadStartTime(); if (option->getAsBool(PREF_ENABLE_MMAP) && option->get(PREF_FILE_ALLOCATION) != V_NONE && - getRequestGroup()->getPieceStorage()->getDiskAdaptor()->size() <= - option->getAsLLInt(PREF_MAX_MMAP_LIMIT)) { - getRequestGroup()->getPieceStorage()->getDiskAdaptor()->enableMmap(); + diskAdaptor->size() <= option->getAsLLInt(PREF_MAX_MMAP_LIMIT)) { + diskAdaptor->enableMmap(); } if (getNextCommand()) { // Reset download start time of PeerStat because it is started // before file allocation begins. - const std::shared_ptr<DownloadContext>& dctx = - getRequestGroup()->getDownloadContext(); - const std::vector<std::shared_ptr<FileEntry>>& fileEntries = - dctx->getFileEntries(); + const auto& fileEntries = dctx->getFileEntries(); for (auto& f : fileEntries) { const auto& reqs = f->getInFlightRequests(); for (auto& req : reqs) { - const std::shared_ptr<PeerStat>& peerStat = req->getPeerStat(); + const auto& peerStat = req->getPeerStat(); if (peerStat) { peerStat->downloadStart(); } @@ -92,10 +92,10 @@ void StreamFileAllocationEntry::prepareForNextAction( e->setNoWait(true); commands.push_back(popNextCommand()); // try remaining uris - getRequestGroup()->createNextCommandWithAdj(commands, e, -1); + rg->createNextCommandWithAdj(commands, e, -1); } else { - getRequestGroup()->createNextCommandWithAdj(commands, e, 0); + rg->createNextCommandWithAdj(commands, e, 0); } } |
