From 41121e09f7cf6ed4a95797a80da63bca1d4884cd Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 12 Jul 2013 22:59:49 +0900 Subject: [PATCH] Use std::unique_ptr for Metalink objects --- src/ChunkChecksum.cc | 4 +- src/ChunkChecksum.h | 2 +- src/Context.cc | 10 +- src/DownloadContext.cc | 4 +- src/DownloadContext.h | 6 +- src/Metalink2RequestGroup.cc | 175 +++++++++++++-------------- src/Metalink2RequestGroup.h | 8 +- src/MetalinkEntry.cc | 137 +++++++++------------ src/MetalinkEntry.h | 29 ++--- src/MetalinkParserController.cc | 62 +++++----- src/MetalinkParserController.h | 21 ++-- src/MetalinkParserStateMachine.cc | 10 +- src/MetalinkParserStateMachine.h | 7 +- src/MetalinkResource.h | 4 +- src/Metalinker.cc | 68 ++++------- src/Metalinker.h | 19 ++- src/RequestGroupMan.cc | 3 +- src/metalink_helper.cc | 78 +++++------- src/metalink_helper.h | 21 ++-- test/MetalinkEntryTest.cc | 47 +++---- test/MetalinkHelperTest.cc | 54 ++++----- test/MetalinkParserControllerTest.cc | 168 ++++++++++++------------- test/MetalinkProcessorTest.cc | 141 +++++++++------------ test/MetalinkerTest.cc | 23 ++-- 24 files changed, 504 insertions(+), 597 deletions(-) diff --git a/src/ChunkChecksum.cc b/src/ChunkChecksum.cc index 44748c87..68e76b1e 100644 --- a/src/ChunkChecksum.cc +++ b/src/ChunkChecksum.cc @@ -80,9 +80,9 @@ void ChunkChecksum::setHashType(const std::string& hashType) hashType_ = hashType; } -void ChunkChecksum::setPieceHashes(const std::vector& pieceHashes) +void ChunkChecksum::setPieceHashes(std::vector pieceHashes) { - pieceHashes_ = pieceHashes; + pieceHashes_ = std::move(pieceHashes); } } // namespace aria2 diff --git a/src/ChunkChecksum.h b/src/ChunkChecksum.h index f1c0580c..4d82528a 100644 --- a/src/ChunkChecksum.h +++ b/src/ChunkChecksum.h @@ -64,7 +64,7 @@ public: const std::string& getPieceHash(size_t index) const; - void setPieceHashes(const std::vector& pieceHashes); + void setPieceHashes(std::vector pieceHashes); const std::vector& getPieceHashes() const { return pieceHashes_; diff --git a/src/Context.cc b/src/Context.cc index 1d1bb315..27ca9a3f 100644 --- a/src/Context.cc +++ b/src/Context.cc @@ -99,12 +99,10 @@ namespace { void showMetalinkFile (const std::string& uri, const std::shared_ptr