From 9eff8100ef28ccda14161a35628c51063cf66f66 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 2 Mar 2017 22:40:36 +0900 Subject: Refactor --- src/BtFileAllocationEntry.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/BtFileAllocationEntry.cc') 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>& 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>& 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 = - 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(); } } -- cgit