DownloadContext, FileEntry: Use move semantics to path parameter in ctor

pull/235/merge
Tatsuhiro Tsujikawa 2014-06-04 22:43:29 +09:00
parent 9b54272190
commit d1d5ea5b21
5 changed files with 9 additions and 9 deletions

View File

@ -59,7 +59,7 @@ DownloadContext::DownloadContext()
DownloadContext::DownloadContext(int32_t pieceLength,
int64_t totalLength,
const std::string& path)
std::string path)
: ownerRequestGroup_(nullptr),
attrs_(MAX_CTX_ATTR),
downloadStopTime_(0),
@ -68,8 +68,8 @@ DownloadContext::DownloadContext(int32_t pieceLength,
knowsTotalLength_(true),
acceptMetalink_(true)
{
std::shared_ptr<FileEntry> fileEntry(new FileEntry(path, totalLength, 0));
fileEntries_.push_back(fileEntry);
fileEntries_.push_back
(std::make_shared<FileEntry>(std::move(path), totalLength, 0));
}
DownloadContext::~DownloadContext() {}

View File

@ -97,7 +97,7 @@ public:
// should be escaped with util::escapePath(...).
DownloadContext(int32_t pieceLength,
int64_t totalLength,
const std::string& path = A2STR::NIL);
std::string path = A2STR::NIL);
~DownloadContext();

View File

@ -66,12 +66,12 @@ bool FileEntry::RequestFaster::operator()
return lspd > rspd || (lspd == rspd && lhs.get() < rhs.get());
}
FileEntry::FileEntry(const std::string& path, int64_t length, int64_t offset,
FileEntry::FileEntry(std::string path, int64_t length, int64_t offset,
const std::vector<std::string>& uris)
: length_(length),
offset_(offset),
uris_(uris.begin(), uris.end()),
path_(path),
path_(std::move(path)),
lastFasterReplace_(0),
maxConnectionPerServer_(1),
requested_(true),

View File

@ -99,7 +99,7 @@ private:
public:
FileEntry();
FileEntry(const std::string& path, int64_t length, int64_t offset,
FileEntry(std::string path, int64_t length, int64_t offset,
const std::vector<std::string>& uris = std::vector<std::string>());
~FileEntry();

View File

@ -230,8 +230,8 @@ createBtMagnetRequestGroup
auto option = util::copy(optionTemplate);
auto gid = getGID(option);
auto rg = std::make_shared<RequestGroup>(gid, option);
auto dctx = std::make_shared<DownloadContext>(METADATA_PIECE_SIZE, 0,
A2STR::NIL);
auto dctx = std::make_shared<DownloadContext>(METADATA_PIECE_SIZE, 0);
// We only know info hash. Total Length is unknown at this moment.
dctx->markTotalLengthIsUnknown();
rg->setFileAllocationEnabled(false);