2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Use std::vector::reserve() for fileEntries and pieceHashes in
	bittorrent_helper
	* src/bittorrent_helper.cc
pull/1/head
Tatsuhiro Tsujikawa 2009-07-03 15:53:37 +00:00
parent e45a0e7e5f
commit e1d63f3aea
2 changed files with 8 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use std::vector::reserve() for fileEntries and pieceHashes in
bittorrent_helper
* src/bittorrent_helper.cc
2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed calls to Request::resetUrl() in AbstractCommand.cc.

View File

@ -112,6 +112,7 @@ static void extractPieceHash(const SharedHandle<DownloadContext>& ctx,
size_t numPieces)
{
std::vector<std::string> pieceHashes;
pieceHashes.reserve(numPieces);
for(size_t i = 0; i < numPieces; ++i) {
pieceHashes.push_back(Util::toHex(hashData.data()+i*hashLength,
hashLength));
@ -184,6 +185,7 @@ static void extractFileEntries
const BDE& filesList = infoDict[C_FILES];
std::vector<SharedHandle<FileEntry> > fileEntries;
if(filesList.isList()) {
fileEntries.reserve(filesList.size());
uint64_t length = 0;
off_t offset = 0;
// multi-file mode