Browse Source

2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Replaced std:copy with insert.
	* src/DefaultBtMessageDispatcher.cc
	* src/DefaultPieceStorage.cc
	* src/DownloadEngineFactory.cc
	* src/RequestGroup.cc
Tatsuhiro Tsujikawa 17 years ago
parent
commit
e4b0446c61
5 changed files with 22 additions and 10 deletions
  1. 8 0
      ChangeLog
  2. 1 1
      src/DefaultBtMessageDispatcher.cc
  3. 1 1
      src/DefaultPieceStorage.cc
  4. 10 6
      src/DownloadEngineFactory.cc
  5. 2 2
      src/RequestGroup.cc

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-05-18  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Replaced std:copy with insert.
+	* src/DefaultBtMessageDispatcher.cc
+	* src/DefaultPieceStorage.cc
+	* src/DownloadEngineFactory.cc
+	* src/RequestGroup.cc
+
 2008-05-17  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Included SocketCore.h to fix compiler warning.

+ 1 - 1
src/DefaultBtMessageDispatcher.cc

@@ -98,7 +98,7 @@ void DefaultBtMessageDispatcher::sendMessages() {
       break;
     }
   }
-  std::copy(tempQueue.begin(), tempQueue.end(), std::back_inserter(messageQueue));
+  messageQueue.insert(messageQueue.end(), tempQueue.begin(), tempQueue.end());
 }
 
 class HandleEvent {

+ 1 - 1
src/DefaultPieceStorage.cc

@@ -570,7 +570,7 @@ void DefaultPieceStorage::markPieceMissing(size_t index)
 
 void DefaultPieceStorage::addInFlightPiece(const Pieces& pieces)
 {
-  std::copy(pieces.begin(), pieces.end(), std::back_inserter(usedPieces));
+  usedPieces.insert(usedPieces.end(), pieces.begin(), pieces.end());
 }
 
 size_t DefaultPieceStorage::countInFlightPiece()

+ 10 - 6
src/DownloadEngineFactory.cc

@@ -64,10 +64,15 @@ DownloadEngineFactory::newDownloadEngine(Option* op,
 {
   RequestGroups workingSet;
   RequestGroups reservedSet;
-  if((size_t)op->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS) < requestGroups.size()) {
-    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));
+  const size_t MAX_CONCURRENT_DOWNLOADS = op->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS);
+  if(MAX_CONCURRENT_DOWNLOADS < requestGroups.size()) {
+    workingSet.insert(workingSet.end(),
+		      requestGroups.begin(),
+		      requestGroups.begin()+MAX_CONCURRENT_DOWNLOADS);
+
+    reservedSet.insert(reservedSet.end(),
+		       requestGroups.begin()+MAX_CONCURRENT_DOWNLOADS,
+		       requestGroups.end());
   } else {
     workingSet = requestGroups;
   }
@@ -75,8 +80,7 @@ DownloadEngineFactory::newDownloadEngine(Option* op,
   DownloadEngineHandle e(new DownloadEngine());
   e->option = op;
   RequestGroupManHandle
-    requestGroupMan(new RequestGroupMan(workingSet,
-					op->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS)));
+    requestGroupMan(new RequestGroupMan(workingSet, MAX_CONCURRENT_DOWNLOADS));
   requestGroupMan->addReservedGroup(reservedSet);
   e->_requestGroupMan = requestGroupMan;
   e->_fileAllocationMan.reset(new FileAllocationMan());

+ 2 - 2
src/RequestGroup.cc

@@ -505,13 +505,13 @@ void RequestGroup::createNextCommand(std::deque<Command*>& commands,
 	command->setStatus(Command::STATUS_ONESHOT_REALTIME);
 	commands.push_back(command);
       } else {
-	pendingURIs.push_front(uri);
+	pendingURIs.push_back(uri);
       }
     } else {
       _logger->error(MSG_UNRECOGNIZED_URI, req->getUrl().c_str());
     }
   }
-  std::copy(pendingURIs.begin(), pendingURIs.end(), std::front_inserter(_uris));
+  _uris.insert(_uris.begin(), pendingURIs.begin(), pendingURIs.end());
 }
 
 std::string RequestGroup::getFilePath() const