diff options
| -rw-r--r-- | ChangeLog | 31 | ||||
| -rw-r--r-- | src/BtFileAllocationEntry.cc | 3 | ||||
| -rw-r--r-- | src/DefaultBtContext.cc | 2 | ||||
| -rw-r--r-- | src/DefaultBtMessageDispatcher.cc | 5 | ||||
| -rw-r--r-- | src/DefaultBtRequestFactory.cc | 3 | ||||
| -rw-r--r-- | src/DefaultPieceStorage.cc | 2 | ||||
| -rw-r--r-- | src/DelegatingPeerListProcessor.cc | 3 | ||||
| -rw-r--r-- | src/DownloadEngineFactory.cc | 7 | ||||
| -rw-r--r-- | src/MetalinkEntry.cc | 2 | ||||
| -rw-r--r-- | src/MetalinkParserController.cc | 2 | ||||
| -rw-r--r-- | src/RequestGroup.cc | 2 | ||||
| -rw-r--r-- | src/RequestGroupMan.cc | 7 | ||||
| -rw-r--r-- | src/StreamFileAllocationEntry.cc | 5 | ||||
| -rw-r--r-- | src/a2algo.h | 4 | ||||
| -rw-r--r-- | src/main.cc | 10 | ||||
| -rw-r--r-- | src/version_usage.cc | 1 | ||||
| -rw-r--r-- | test/StreamUriListParserTest.cc | 53 |
17 files changed, 65 insertions, 77 deletions
@@ -1,5 +1,36 @@ 2008-02-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> + Added std namespace to copy, remove_copy, back_inserter, + front_inserter. + * src/RequestGroupMan.cc + * src/DefaultPieceStorage.cc + * src/StreamFileAllocationEntry.cc + * src/BtFileAllocationEntry.cc + * src/RequestGroup.cc + * src/MetalinkEntry.cc + * src/DelegatingPeerListProcessor.cc + * src/DefaultBtRequestFactory.cc + * src/DefaultBtMessageDispatcher.cc + * src/version_usage.cc: Included <algorithm> + * src/main.cc + * src/MetalinkParserController.cc + * src/DefaultBtContext.cc + * src/DownloadEngineFactory.cc + * src/a2algo.h + + Removed. + * test/StreamUriListParserTest.cc + +2008-02-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> + + Use PREF_MAX_DOWNLOAD_LIMIT as a threshold for + ActivePeerConnectionCommand when it is given and + PREF_MAX_DOWNLOAD_LIMIT < default threshold. + * src/ActivePeerConnectionCommand.{h, cc} + * src/BtSetup.cc + +2008-02-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> + Only add socket to DownloadEngine's select routine when peer or localhost is unchoked and interested. This lowers CPU usage a little bit. diff --git a/src/BtFileAllocationEntry.cc b/src/BtFileAllocationEntry.cc index c27ea4c1..19f70d8f 100644 --- a/src/BtFileAllocationEntry.cc +++ b/src/BtFileAllocationEntry.cc @@ -37,6 +37,7 @@ #include "RequestGroup.h" #include "Command.h" #include "DownloadEngine.h" +#include <algorithm> namespace aria2 { @@ -50,7 +51,7 @@ Commands BtFileAllocationEntry::prepareForNextAction(DownloadEngine* e) Commands commands = BtSetup().setup(_requestGroup, e, e->option); if(!_requestGroup->downloadFinished()) { Commands streamCommands = _requestGroup->createNextCommandWithAdj(e, 0); - copy(streamCommands.begin(), streamCommands.end(), back_inserter(commands)); + std::copy(streamCommands.begin(), streamCommands.end(), std::back_inserter(commands)); } return commands; } diff --git a/src/DefaultBtContext.cc b/src/DefaultBtContext.cc index 891006e5..264d3fac 100644 --- a/src/DefaultBtContext.cc +++ b/src/DefaultBtContext.cc @@ -162,7 +162,7 @@ void DefaultBtContext::extractFileEntries(const Dictionary* infoDic, } std::deque<std::string> uris; - std::transform(urlList.begin(), urlList.end(), back_inserter(uris), + std::transform(urlList.begin(), urlList.end(), std::back_inserter(uris), std::bind2nd(std::plus<std::string>(), "/"+name+"/"+path)); FileEntryHandle fileEntry(new FileEntry(path, lengthData->toLLInt(), diff --git a/src/DefaultBtMessageDispatcher.cc b/src/DefaultBtMessageDispatcher.cc index 09233685..9d9ad8d8 100644 --- a/src/DefaultBtMessageDispatcher.cc +++ b/src/DefaultBtMessageDispatcher.cc @@ -49,6 +49,7 @@ #include "Piece.h" #include "LogFactory.h" #include "Logger.h" +#include <algorithm> namespace aria2 { @@ -100,7 +101,7 @@ void DefaultBtMessageDispatcher::sendMessages() { break; } } - copy(tempQueue.begin(), tempQueue.end(), back_inserter(messageQueue)); + std::copy(tempQueue.begin(), tempQueue.end(), std::back_inserter(messageQueue)); } // Cancel sending piece message to peer. @@ -254,7 +255,7 @@ DefaultBtMessageDispatcher::getOutstandingRequest(int32_t index, int32_t begin, void DefaultBtMessageDispatcher::removeOutstandingRequest(const RequestSlot& slot) { RequestSlots temp; - std::remove_copy(requestSlots.begin(), requestSlots.end(), back_inserter(temp), slot); + std::remove_copy(requestSlots.begin(), requestSlots.end(), std::back_inserter(temp), slot); requestSlots = temp; } diff --git a/src/DefaultBtRequestFactory.cc b/src/DefaultBtRequestFactory.cc index 6a94461c..55d14bf5 100644 --- a/src/DefaultBtRequestFactory.cc +++ b/src/DefaultBtRequestFactory.cc @@ -43,6 +43,7 @@ #include "BtMessageFactory.h" #include "BtMessage.h" #include "BtRegistry.h" +#include <algorithm> namespace aria2 { @@ -80,7 +81,7 @@ void DefaultBtRequestFactory::removeCompletedPiece() { void DefaultBtRequestFactory::removeTargetPiece(const PieceHandle& piece) { Pieces temp; - remove_copy(pieces.begin(), pieces.end(), back_inserter(temp), piece); + std::remove_copy(pieces.begin(), pieces.end(), std::back_inserter(temp), piece); pieces = temp; dispatcher->doAbortOutstandingRequestAction(piece); pieceStorage->cancelPiece(piece); diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index 75ddf769..39f34382 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -579,7 +579,7 @@ void DefaultPieceStorage::markPieceMissing(int32_t index) void DefaultPieceStorage::addInFlightPiece(const Pieces& pieces) { - copy(pieces.begin(), pieces.end(), back_inserter(usedPieces)); + std::copy(pieces.begin(), pieces.end(), std::back_inserter(usedPieces)); } int32_t DefaultPieceStorage::countInFlightPiece() diff --git a/src/DelegatingPeerListProcessor.cc b/src/DelegatingPeerListProcessor.cc index 77e21581..a0a3a53e 100644 --- a/src/DelegatingPeerListProcessor.cc +++ b/src/DelegatingPeerListProcessor.cc @@ -35,6 +35,7 @@ #include "DefaultPeerListProcessor.h" #include "CompactPeerListProcessor.h" #include "Peer.h" +#include <algorithm> namespace aria2 { @@ -55,7 +56,7 @@ Peers DelegatingPeerListProcessor::extractPeer(const MetaEntry* peersEntry) { PeerListProcessorHandle processor = *itr; if(processor->canHandle(peersEntry)) { Peers tempPeers = processor->extractPeer(peersEntry); - copy(tempPeers.begin(), tempPeers.end(), back_inserter(peers)); + std::copy(tempPeers.begin(), tempPeers.end(), std::back_inserter(peers)); break; } } diff --git a/src/DownloadEngineFactory.cc b/src/DownloadEngineFactory.cc index 0d12da65..33c475ff 100644 --- a/src/DownloadEngineFactory.cc +++ b/src/DownloadEngineFactory.cc @@ -50,6 +50,7 @@ #include "AutoSaveCommand.h" #include "HaveEraseCommand.h" #include "DownloadResult.h" +#include <algorithm> namespace aria2 { @@ -63,9 +64,9 @@ DownloadEngineFactory::newDownloadEngine(Option* op, RequestGroups workingSet; RequestGroups reservedSet; if(op->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS) < (int32_t)requestGroups.size()) { - copy(requestGroups.begin(), requestGroups.begin()+op->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS), back_inserter(workingSet)); - copy(requestGroups.begin()+op->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS), - requestGroups.end(), back_inserter(reservedSet)); + std::copy(requestGroups.begin(), requestGroups.begin()+op->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS), std::back_inserter(workingSet)); + std::copy(requestGroups.begin()+op->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS), + requestGroups.end(), std::back_inserter(reservedSet)); } else { workingSet = requestGroups; } diff --git a/src/MetalinkEntry.cc b/src/MetalinkEntry.cc index 9592750f..810681c7 100644 --- a/src/MetalinkEntry.cc +++ b/src/MetalinkEntry.cc @@ -175,7 +175,7 @@ std::deque<SharedHandle<FileEntry> > MetalinkEntry::toFileEntry(const std::deque<SharedHandle<MetalinkEntry> >& metalinkEntries) { std::deque<SharedHandle<FileEntry> > entries; - std::transform(metalinkEntries.begin(), metalinkEntries.end(), back_inserter(entries), + std::transform(metalinkEntries.begin(), metalinkEntries.end(), std::back_inserter(entries), mem_fun_sh(&MetalinkEntry::getFile)); return entries; } diff --git a/src/MetalinkParserController.cc b/src/MetalinkParserController.cc index 1b3bf3ea..50c1d7ea 100644 --- a/src/MetalinkParserController.cc +++ b/src/MetalinkParserController.cc @@ -366,7 +366,7 @@ void MetalinkParserController::commitChunkChecksumTransaction() std::sort(_tempChunkChecksums.begin(), _tempChunkChecksums.end(), Ascend1st<std::pair<int32_t, std::string> >()); std::deque<std::string> checksums; std::transform(_tempChunkChecksums.begin(), _tempChunkChecksums.end(), - back_inserter(checksums), select2nd<std::pair<int32_t, std::string> >()); + std::back_inserter(checksums), select2nd<std::pair<int32_t, std::string> >()); _tChunkChecksum->setChecksums(checksums); _tEntry->chunkChecksum = _tChunkChecksum; } diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index c352c714..08488011 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -443,7 +443,7 @@ Commands RequestGroup::createNextCommand(DownloadEngine* e, int32_t numCommand, _logger->error(MSG_UNRECOGNIZED_URI, req->getUrl().c_str()); } } - copy(pendingURIs.begin(), pendingURIs.end(), front_inserter(_uris)); + std::copy(pendingURIs.begin(), pendingURIs.end(), std::front_inserter(_uris)); return commands; } diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index c49b2168..39dfe852 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -45,6 +45,7 @@ #include <iomanip> #include <sstream> #include <numeric> +#include <algorithm> namespace aria2 { @@ -119,7 +120,7 @@ void RequestGroupMan::removeStoppedGroup() RequestGroups nextGroups = (*itr)->postDownloadProcessing(); if(nextGroups.size() > 0) { _logger->debug("Adding %d RequestGroups as a result of PostDownloadHandler.", (int32_t)nextGroups.size()); - copy(nextGroups.rbegin(), nextGroups.rend(), front_inserter(_reservedGroups)); + std::copy(nextGroups.rbegin(), nextGroups.rend(), std::front_inserter(_reservedGroups)); } } else { (*itr)->getProgressInfoFile()->save(); @@ -163,7 +164,7 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e) _downloadResults.push_back(groupToAdd->createDownloadResult()); } } - copy(temp.begin(), temp.end(), front_inserter(_reservedGroups)); + std::copy(temp.begin(), temp.end(), std::front_inserter(_reservedGroups)); if(count > 0) { _logger->debug("%d RequestGroup(s) added.", count); } @@ -177,7 +178,7 @@ Commands RequestGroupMan::getInitialCommands(DownloadEngine* e) try { if((*itr)->isDependencyResolved()) { Commands nextCommands = (*itr)->createInitialCommand(e); - copy(nextCommands.begin(), nextCommands.end(), back_inserter(commands)); + std::copy(nextCommands.begin(), nextCommands.end(), std::back_inserter(commands)); ++itr; } else { _reservedGroups.push_front((*itr)); diff --git a/src/StreamFileAllocationEntry.cc b/src/StreamFileAllocationEntry.cc index 20a161cb..c7db4a83 100644 --- a/src/StreamFileAllocationEntry.cc +++ b/src/StreamFileAllocationEntry.cc @@ -40,6 +40,7 @@ #include "prefs.h" #include "RequestGroup.h" #include "InitiateConnectionCommandFactory.h" +#include <algorithm> namespace aria2 { @@ -59,7 +60,7 @@ Commands StreamFileAllocationEntry::prepareForNextAction(DownloadEngine* e) commands.push_back(popNextCommand()); // try remaining uris Commands streamCommands = _requestGroup->createNextCommandWithAdj(e, -1); - copy(streamCommands.begin(), streamCommands.end(), back_inserter(commands)); + std::copy(streamCommands.begin(), streamCommands.end(), std::back_inserter(commands)); } else { if(_currentRequest.isNull()) { commands = _requestGroup->createNextCommandWithAdj(e, 0); @@ -69,7 +70,7 @@ Commands StreamFileAllocationEntry::prepareForNextAction(DownloadEngine* e) _currentRequest, _requestGroup, e); commands.push_back(command); - copy(streamCommands.begin(), streamCommands.end(), back_inserter(commands)); + std::copy(streamCommands.begin(), streamCommands.end(), std::back_inserter(commands)); } } return commands; diff --git a/src/a2algo.h b/src/a2algo.h index e041b3c4..1a5a8aab 100644 --- a/src/a2algo.h +++ b/src/a2algo.h @@ -35,6 +35,8 @@ #ifndef _D_A2_ALGO_H_ #define _D_A2_ALGO_H_ +#include <algorithm> + namespace aria2 { template<typename InputIterator, typename OutputIterator> @@ -43,7 +45,7 @@ OutputIterator ncopy(InputIterator first, InputIterator last, { OutputIterator x = destination; for(int32_t i = 0; i < count; ++i) { - x = copy(first, last, destination); + x = std::copy(first, last, destination); } return x; } diff --git a/src/main.cc b/src/main.cc index f53df1c2..eed8cf49 100644 --- a/src/main.cc +++ b/src/main.cc @@ -127,7 +127,7 @@ void downloadBitTorrent(Option* op, const std::deque<std::string>& uri) } std::deque<std::string> xargs; ncopy(nargs.begin(), nargs.end(), op->getAsInt(PREF_SPLIT), - back_inserter(xargs)); + std::back_inserter(xargs)); RequestGroupHandle rg = new RequestGroup(op, xargs); DefaultBtContextHandle btContext = new DefaultBtContext(); @@ -167,14 +167,14 @@ void downloadUriList(Option* op, std::istream& in) for(std::deque<std::string>::const_iterator itr = unfoldedURIs.begin(); itr != unfoldedURIs.end(); ++itr) { std::deque<std::string> xuris; - ncopy(itr, itr+1, op->getAsInt(PREF_SPLIT), back_inserter(xuris)); + ncopy(itr, itr+1, op->getAsInt(PREF_SPLIT), std::back_inserter(xuris)); SharedHandle<RequestGroup> rg = createRequestGroup(op, xuris); groups.push_back(rg); } } else if(uris.size() > 0) { std::deque<std::string> xuris; ncopy(uris.begin(), uris.end(), op->getAsInt(PREF_SPLIT), - back_inserter(xuris)); + std::back_inserter(xuris)); SharedHandle<RequestGroup> rg = createRequestGroup(op, xuris); groups.push_back(rg); } @@ -209,14 +209,14 @@ void downloadUri(Option* op, const std::deque<std::string>& uris) itr != nargs.end(); ++itr) { std::deque<std::string> xuris; ncopy(itr, itr+1, op->getAsInt(PREF_SPLIT), - back_inserter(xuris)); + std::back_inserter(xuris)); RequestGroupHandle rg = createRequestGroup(op, xuris); groups.push_back(rg); } } else { std::deque<std::string> xargs; ncopy(nargs.begin(), nargs.end(), op->getAsInt(PREF_SPLIT), - back_inserter(xargs)); + std::back_inserter(xargs)); RequestGroupHandle rg = createRequestGroup(op, xargs, op->get(PREF_OUT)); groups.push_back(rg); } diff --git a/src/version_usage.cc b/src/version_usage.cc index f3aef4e7..cf689b33 100644 --- a/src/version_usage.cc +++ b/src/version_usage.cc @@ -46,6 +46,7 @@ #include "prefs.h" #include <iostream> #include <iterator> +#include <algorithm> namespace aria2 { diff --git a/test/StreamUriListParserTest.cc b/test/StreamUriListParserTest.cc deleted file mode 100644 index fbb7f32a..00000000 --- a/test/StreamUriListParserTest.cc +++ /dev/null @@ -1,53 +0,0 @@ -#include "StreamUriListParser.h" -#include "Exception.h" -#include "Util.h" -#include <sstream> -#include <algorithm> -#include <iostream> -#include <iterator> -#include <cppunit/extensions/HelperMacros.h> - -using namespace std; - -class StreamUriListParserTest : public CppUnit::TestFixture { - - CPPUNIT_TEST_SUITE(StreamUriListParserTest); - CPPUNIT_TEST(testHasNext); - CPPUNIT_TEST_SUITE_END(); -private: - std::stringlist2String(const Strings& src); -public: - void setUp() { - } - - void testHasNext(); -}; - - -CPPUNIT_TEST_SUITE_REGISTRATION( StreamUriListParserTest ); - -std::stringStreamUriListParserTest::list2String(const Strings& src) -{ - ostringstream strm; - copy(src.begin(), src.end(), ostream_iterator<string>(strm, " ")); - return Util::trim(strm.str()); -} - -void StreamUriListParserTest::testHasNext() -{ - stringstream s; - s << "http://localhost/index.html http://localhost2/index.html\n" - << "ftp://localhost/aria2.tar.bz2"; - - StreamUriListParser flp(s); - - CPPUNIT_ASSERT(flp.hasNext()); - CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/index.html http://localhost2/index.html"), list2String(flp.next())); - CPPUNIT_ASSERT(flp.hasNext()); - CPPUNIT_ASSERT_EQUAL(std::string("ftp://localhost/aria2.tar.bz2"), - list2String(flp.next())); - CPPUNIT_ASSERT(flp.hasNext()); - CPPUNIT_ASSERT_EQUAL(std::string(""), - list2String(flp.next())); - CPPUNIT_ASSERT(!flp.hasNext()); -} |
