diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-10-13 11:49:04 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-10-13 11:49:04 +0200 |
commit | 909c17c2a8a142a57d65a9c735add7ce0a6deadf (patch) | |
tree | b5656a83bd94d78c1471551ef8c02981a4349e4c /filedistribution/src | |
parent | 6b070580d71f87f150c35d235fa963f9766c7f5b (diff) |
Avoid going via temporary.
Diffstat (limited to 'filedistribution/src')
-rw-r--r-- | filedistribution/src/vespa/filedistribution/distributor/filedownloader.cpp | 6 | ||||
-rw-r--r-- | filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.cpp | 13 |
2 files changed, 8 insertions, 11 deletions
diff --git a/filedistribution/src/vespa/filedistribution/distributor/filedownloader.cpp b/filedistribution/src/vespa/filedistribution/distributor/filedownloader.cpp index 6455d6e67ae..0ab21e8cc42 100644 --- a/filedistribution/src/vespa/filedistribution/distributor/filedownloader.cpp +++ b/filedistribution/src/vespa/filedistribution/distributor/filedownloader.cpp @@ -285,7 +285,7 @@ FileDownloader::pathToCompletedFile(const std::string& fileReference) const { boost::optional<FileDownloader::ResumeDataBuffer> FileDownloader::getResumeData(const std::string& fileReference) { - LOG(debug, "%s", ("Reading resume data for " + fileReference).c_str()); + LOG(debug, "Reading resume data for %s ", fileReference.c_str()); try { fs::path path = (_dbPath / fileReference).string() + resumeDataSuffix; if (fs::exists(path)) { @@ -294,7 +294,7 @@ FileDownloader::getResumeData(const std::string& fileReference) { std::istream_iterator<char> iterator(file), end; std::copy(iterator, end, std::back_inserter(result)); - LOG(debug, "%s", ("Successfully retrieved resume data for " + fileReference).c_str()); + LOG(debug, "Successfully retrieved resume data for %s ", fileReference.c_str()); if (result.size() < 50) { LOG(info, "Very small resume file %zu bytes.", result.size()); } @@ -303,7 +303,7 @@ FileDownloader::getResumeData(const std::string& fileReference) { } } catch(...) { //resume data is only an optimization - LOG(info, "%s", ("Error while reading resume data for " + fileReference).c_str()); + LOG(info, "Error while reading resume data for %s", fileReference.c_str()); } return boost::optional<ResumeDataBuffer>(); } diff --git a/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.cpp b/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.cpp index b01acb10f87..e0338cffd52 100644 --- a/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.cpp +++ b/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.cpp @@ -13,11 +13,11 @@ LOG_SETUP(".filedistributionmodel"); namespace fs = boost::filesystem; using filedistribution::ZKFileDBModel; +using std::make_shared; namespace { //peer format: hostName:port - void addPeerEntry(const std::string& peer, filedistribution::FileDistributionModelImpl::PeerEntries& result) { @@ -73,8 +73,7 @@ struct FileDistributionModelImpl::DeployedFilesChangedCallback : std::weak_ptr<FileDistributionModelImpl> _parent; - DeployedFilesChangedCallback( - const std::shared_ptr<FileDistributionModelImpl> & parent) + DeployedFilesChangedCallback(const std::shared_ptr<FileDistributionModelImpl> & parent) :_parent(parent) {} @@ -111,7 +110,7 @@ FileDistributionModelImpl::getPeers(const std::string& fileReference, size_t max LOG(debug, "Found %zu peers for path '%s'", result.size(), path.string().c_str()); return result; } catch(ZKNodeDoesNotExistsException&) { - LOG(debug, "%s", ("No peer entries available for " + fileReference).c_str()); + LOG(debug, "No peer entries available for '%s'", fileReference.c_str()); return PeerEntries(); } } @@ -166,8 +165,7 @@ std::set<std::string> FileDistributionModelImpl::getFilesToDownload() { DeployedFilesToDownload d(_zk.get()); std::vector<std::string> deployed = d.getDeployedFilesToDownload(_hostName, - DeployedFilesChangedCallback::SP( - new DeployedFilesChangedCallback(shared_from_this()))); + make_shared<DeployedFilesChangedCallback>(shared_from_this())); std::set<std::string> result(deployed.begin(), deployed.end()); @@ -186,8 +184,7 @@ FileDistributionModelImpl::updateActiveFileReferences( std::sort(sortedFileReferences.begin(), sortedFileReferences.end()); LockGuard guard(_activeFileReferencesMutex); - bool changed = - sortedFileReferences != _activeFileReferences; + bool changed = sortedFileReferences != _activeFileReferences; sortedFileReferences.swap(_activeFileReferences); return changed; |