From e1d63f3aeab9b0fa472a1b5bfcd5a95eabe618ec Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 3 Jul 2009 15:53:37 +0000 Subject: [PATCH] 2009-07-04 Tatsuhiro Tsujikawa Use std::vector::reserve() for fileEntries and pieceHashes in bittorrent_helper * src/bittorrent_helper.cc --- ChangeLog | 6 ++++++ src/bittorrent_helper.cc | 2 ++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index ff3081d7..77182704 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-07-04 Tatsuhiro Tsujikawa + + Use std::vector::reserve() for fileEntries and pieceHashes in + bittorrent_helper + * src/bittorrent_helper.cc + 2009-07-04 Tatsuhiro Tsujikawa Removed calls to Request::resetUrl() in AbstractCommand.cc. diff --git a/src/bittorrent_helper.cc b/src/bittorrent_helper.cc index 698a4e7b..7f502140 100644 --- a/src/bittorrent_helper.cc +++ b/src/bittorrent_helper.cc @@ -112,6 +112,7 @@ static void extractPieceHash(const SharedHandle& ctx, size_t numPieces) { std::vector 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 > fileEntries; if(filesList.isList()) { + fileEntries.reserve(filesList.size()); uint64_t length = 0; off_t offset = 0; // multi-file mode