From 3756d79bc92df17e1ba38b6d46f75992cce6689d Mon Sep 17 00:00:00 2001 From: Steven Hahn <hahnse@ornl.gov> Date: Mon, 28 Nov 2016 22:08:19 -0500 Subject: [PATCH] Address issues from clang-tidy: performance-unnecessary-copy-initialization --- Framework/API/src/FileFinder.cpp | 3 +-- .../API/src/ImplicitFunctionParserFactory.cpp | 2 +- Framework/API/src/Run.cpp | 2 +- .../Crystal/inc/MantidCrystal/LoadIsawPeaks.h | 1 - Framework/Crystal/src/CalculatePeaksHKL.cpp | 2 +- Framework/Crystal/src/IndexPeaks.cpp | 2 +- Framework/Crystal/src/LoadIsawPeaks.cpp | 23 +++++++------------ .../Crystal/src/PredictFractionalPeaks.cpp | 2 +- Framework/Crystal/src/PredictPeaks.cpp | 2 +- Framework/Crystal/src/SCDCalibratePanels.cpp | 2 +- Framework/Crystal/src/ShowPossibleCells.cpp | 2 +- .../src/Algorithms/LeBailFunction.cpp | 17 ++++---------- .../src/Algorithms/PlotPeakByLogValue.cpp | 2 +- .../src/ImggAggregateWavelengths.cpp | 2 +- Framework/DataHandling/src/Load.cpp | 2 +- Framework/DataHandling/src/LoadEventNexus.cpp | 3 +-- Framework/DataHandling/src/LoadFITS.cpp | 12 ++++------ Framework/DataHandling/src/LoadInstrument.cpp | 2 +- Framework/DataHandling/src/LoadNXcanSAS.cpp | 2 +- Framework/DataHandling/src/SaveGSS.cpp | 3 +-- .../inc/MantidDataObjects/VectorColumn.h | 3 +-- .../src/Crystal/CompositeBraggScatterer.cpp | 2 +- .../Instrument/InstrumentDefinitionParser.cpp | 2 +- Framework/Kernel/src/InstrumentInfo.cpp | 2 +- .../LiveData/src/SNSLiveEventDataListener.cpp | 2 +- .../MDAlgorithms/src/CompareMDWorkspaces.cpp | 3 +-- Framework/MDAlgorithms/src/LoadILLAscii.cpp | 2 +- Framework/MDAlgorithms/src/MergeMD.cpp | 3 +-- Framework/MDAlgorithms/src/MinusMD.cpp | 3 +-- Framework/MDAlgorithms/src/PlusMD.cpp | 3 +-- .../MDAlgorithms/src/SlicingAlgorithm.cpp | 12 ++++------ .../src/SCARFTomoReconstruction.cpp | 5 ++-- .../src/MantidWebServiceAPIJobManager.cpp | 8 +++---- 33 files changed, 54 insertions(+), 84 deletions(-) diff --git a/Framework/API/src/FileFinder.cpp b/Framework/API/src/FileFinder.cpp index a9b808e4915..5e6f1f8d668 100644 --- a/Framework/API/src/FileFinder.cpp +++ b/Framework/API/src/FileFinder.cpp @@ -134,9 +134,8 @@ std::string FileFinderImpl::getFullPath(const std::string &filename, if (fName.find("*") != std::string::npos) { #endif Poco::Path path(searchPath, fName); - Poco::Path pathPattern(path); std::set<std::string> files; - Kernel::Glob::glob(pathPattern, files, m_globOption); + Kernel::Glob::glob(path, files, m_globOption); if (!files.empty()) { Poco::File matchPath(*files.begin()); if (ignoreDirs && matchPath.isDirectory()) { diff --git a/Framework/API/src/ImplicitFunctionParserFactory.cpp b/Framework/API/src/ImplicitFunctionParserFactory.cpp index 9a13f894941..14e1ab5afd4 100644 --- a/Framework/API/src/ImplicitFunctionParserFactory.cpp +++ b/Framework/API/src/ImplicitFunctionParserFactory.cpp @@ -18,7 +18,7 @@ ImplicitFunctionParserFactoryImpl::create(const std::string &xmlString) const { ImplicitFunctionParser * ImplicitFunctionParserFactoryImpl::createImplicitFunctionParserFromXML( Poco::XML::Element *functionElement) const { - std::string name = functionElement->localName(); + const std::string &name = functionElement->localName(); if (name != "Function") { throw std::runtime_error( "Root node must be a Funtion element. Unable to determine parsers."); diff --git a/Framework/API/src/Run.cpp b/Framework/API/src/Run.cpp index 0e256285d94..c214009079f 100644 --- a/Framework/API/src/Run.cpp +++ b/Framework/API/src/Run.cpp @@ -184,7 +184,7 @@ void Run::integrateProtonCharge(const std::string &logname) const { if (log) { const std::vector<double> logValues = log->valuesAsVector(); double total = std::accumulate(logValues.begin(), logValues.end(), 0.0); - std::string unit = log->units(); + const std::string &unit = log->units(); // Do we need to take account of a unit if (unit.find("picoCoulomb") != std::string::npos) { /// Conversion factor between picoColumbs and microAmp*hours diff --git a/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h b/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h index a20c141abfb..6bd149be3fc 100644 --- a/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h @@ -46,7 +46,6 @@ private: /// Reads calibration/detector section and returns first word of next line std::string ApplyCalibInfo(std::ifstream &in, std::string startChar, - Geometry::Instrument_const_sptr instr_old, Geometry::Instrument_const_sptr instr, double &T0); /// Reads first line of peaks file and returns first word of next line diff --git a/Framework/Crystal/src/CalculatePeaksHKL.cpp b/Framework/Crystal/src/CalculatePeaksHKL.cpp index f59327ce146..7f5b556a522 100644 --- a/Framework/Crystal/src/CalculatePeaksHKL.cpp +++ b/Framework/Crystal/src/CalculatePeaksHKL.cpp @@ -52,7 +52,7 @@ void CalculatePeaksHKL::exec() { const int n_peaks = ws->getNumberPeaks(); OrientedLattice o_lattice = ws->mutableSample().getOrientedLattice(); - Matrix<double> UB = o_lattice.getUB(); + const Matrix<double> &UB = o_lattice.getUB(); DblMatrix UB_inverse(UB); diff --git a/Framework/Crystal/src/IndexPeaks.cpp b/Framework/Crystal/src/IndexPeaks.cpp index dfb86fb5e61..ddc1c214b7d 100644 --- a/Framework/Crystal/src/IndexPeaks.cpp +++ b/Framework/Crystal/src/IndexPeaks.cpp @@ -51,7 +51,7 @@ void IndexPeaks::exec() { } OrientedLattice o_lattice = ws->mutableSample().getOrientedLattice(); - Matrix<double> UB = o_lattice.getUB(); + const Matrix<double> &UB = o_lattice.getUB(); if (!IndexingUtils::CheckUB(UB)) { throw std::runtime_error( diff --git a/Framework/Crystal/src/LoadIsawPeaks.cpp b/Framework/Crystal/src/LoadIsawPeaks.cpp index 5c9ff368422..380f44d976b 100644 --- a/Framework/Crystal/src/LoadIsawPeaks.cpp +++ b/Framework/Crystal/src/LoadIsawPeaks.cpp @@ -108,10 +108,8 @@ void LoadIsawPeaks::exec() { //---------------------------------------------------------------------------------------------- std::string LoadIsawPeaks::ApplyCalibInfo(std::ifstream &in, std::string startChar, - Geometry::Instrument_const_sptr instr_old, Geometry::Instrument_const_sptr instr, double &T0) { - ParameterMap_sptr parMap1 = instr_old->getParameterMap(); ParameterMap_sptr parMap = instr->getParameterMap(); @@ -136,7 +134,7 @@ LoadIsawPeaks::ApplyCalibInfo(std::ifstream &in, std::string startChar, iss >> T0; V3D sampPos = instr->getSample()->getPos(); SCDCalibratePanels::FixUpSourceParameterMap(instr, L1 / 100, sampPos, - parMap1); + parMap); } catch (...) { g_log.error() << "Invalid L1 or Time offset\n"; throw std::invalid_argument("Invalid L1 or Time offset"); @@ -196,7 +194,7 @@ LoadIsawPeaks::ApplyCalibInfo(std::ifstream &in, std::string startChar, } bankName += SbankNum; boost::shared_ptr<const Geometry::IComponent> bank = - getCachedBankByName(bankName, instr_old); + getCachedBankByName(bankName, instr); if (!bank) { g_log.error() << "There is no bank " << bankName @@ -216,7 +214,7 @@ LoadIsawPeaks::ApplyCalibInfo(std::ifstream &in, std::string startChar, bankRot.inverse(); Quat dRot = thisRot * bankRot; - boost::shared_ptr<const Geometry::RectangularDetector> bankR = + auto bankR = boost::dynamic_pointer_cast<const Geometry::RectangularDetector>(bank); if (!bankR) @@ -227,11 +225,10 @@ LoadIsawPeaks::ApplyCalibInfo(std::ifstream &in, std::string startChar, DetWScale = width / bankR->xsize() / 100; DetHtScale = height / bankR->ysize() / 100; } - std::vector<std::string> bankNames; - bankNames.push_back(bankName); + std::vector<std::string> bankNames{bankName}; SCDCalibratePanels::FixUpBankParameterMap( - bankNames, instr, dPos, dRot, DetWScale, DetHtScale, parMap1, false); + bankNames, instr, dPos, dRot, DetWScale, DetHtScale, parMap, false); } return startChar; } @@ -294,13 +291,9 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, // Populate the instrument parameters in this workspace - this works around a // bug tempWS->populateInstrumentParameters(); - Geometry::Instrument_const_sptr instr_old = tempWS->getInstrument(); - auto instr = instr_old; - /*auto map = boost::make_shared<ParameterMap>(); - auto instr = boost::make_shared<const Geometry::Instrument>( - instr_old->baseInstrument(), map);*/ + Geometry::Instrument_const_sptr instr = tempWS->getInstrument(); - std::string s = ApplyCalibInfo(in, "", instr_old, instr, T0); + std::string s = ApplyCalibInfo(in, "", instr, T0); outWS->setInstrument(instr); // Now skip all lines on L1, detector banks, etc. until we get to a block of @@ -565,7 +558,7 @@ void LoadIsawPeaks::appendFile(PeaksWorkspace_sptr outWS, Peak peak = readPeak(outWS, s, in, seqNum, bankName, qSign); // Get the calculated goniometer matrix - Matrix<double> gonMat = uniGonio.getR(); + const Matrix<double> &gonMat = uniGonio.getR(); peak.setGoniometerMatrix(gonMat); peak.setRunNumber(run); diff --git a/Framework/Crystal/src/PredictFractionalPeaks.cpp b/Framework/Crystal/src/PredictFractionalPeaks.cpp index 86a4906756c..d422382a590 100644 --- a/Framework/Crystal/src/PredictFractionalPeaks.cpp +++ b/Framework/Crystal/src/PredictFractionalPeaks.cpp @@ -161,7 +161,7 @@ void PredictFractionalPeaks::exec() { hkl[2] = peak0.getL(); } - Kernel::DblMatrix UB = ol.getUB(); + const Kernel::DblMatrix &UB = ol.getUB(); vector<vector<int>> AlreadyDonePeaks; bool done = false; int ErrPos = 1; // Used to determine position in code of a throw diff --git a/Framework/Crystal/src/PredictPeaks.cpp b/Framework/Crystal/src/PredictPeaks.cpp index 5eb7006a96b..554d29f25bb 100644 --- a/Framework/Crystal/src/PredictPeaks.cpp +++ b/Framework/Crystal/src/PredictPeaks.cpp @@ -216,7 +216,7 @@ void PredictPeaks::exec() { const Sample &sample = inputExperimentInfo->sample(); // Retrieve the OrientedLattice (UnitCell) from the workspace - OrientedLattice orientedLattice = sample.getOrientedLattice(); + const OrientedLattice &orientedLattice = sample.getOrientedLattice(); // Get the UB matrix from it Matrix<double> ub(3, 3, true); diff --git a/Framework/Crystal/src/SCDCalibratePanels.cpp b/Framework/Crystal/src/SCDCalibratePanels.cpp index fdab7d7c0c8..49491c640a0 100644 --- a/Framework/Crystal/src/SCDCalibratePanels.cpp +++ b/Framework/Crystal/src/SCDCalibratePanels.cpp @@ -368,7 +368,7 @@ void SCDCalibratePanels::exec() { "Workspace2D", MyBankNames.size(), nPeaks, nPeaks); TofWksp->setInstrument(inst); OrientedLattice lattice = peaksWs->mutableSample().getOrientedLattice(); - DblMatrix UB = lattice.getUB(); + const DblMatrix &UB = lattice.getUB(); // sort again since edge peaks can trace to other banks peaksWs->sort(criteria); PARALLEL_FOR_IF(Kernel::threadSafe(*ColWksp, *RowWksp, *TofWksp)) diff --git a/Framework/Crystal/src/ShowPossibleCells.cpp b/Framework/Crystal/src/ShowPossibleCells.cpp index 237c467f75c..cd77926624a 100644 --- a/Framework/Crystal/src/ShowPossibleCells.cpp +++ b/Framework/Crystal/src/ShowPossibleCells.cpp @@ -51,7 +51,7 @@ void ShowPossibleCells::exec() { } OrientedLattice o_lattice = ws->sample().getOrientedLattice(); - Matrix<double> UB = o_lattice.getUB(); + const Matrix<double> &UB = o_lattice.getUB(); if (!IndexingUtils::CheckUB(UB)) { throw std::runtime_error( diff --git a/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp b/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp index a85af08502f..ae03de1ca92 100644 --- a/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp +++ b/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp @@ -106,7 +106,7 @@ LeBailFunction::function(const Mantid::HistogramData::HistogramX &xvalues, // Reset output elements to zero std::vector<double> out(xvalues.size(), 0); - auto xvals = xvalues.rawData(); + const auto &xvals = xvalues.rawData(); // Peaks if (calpeaks) { @@ -800,9 +800,7 @@ void LeBailFunction::groupPeaks( if (thispeak_rightbound < rightpeak_leftbound) { // this peak and its right peak are well separated. // finish this group by a copy - vector<pair<double, IPowderDiffPeakFunction_sptr>> peakgroupcopy = - peakgroup; - peakgroupvec.push_back(peakgroupcopy); + peakgroupvec.push_back(peakgroup); // clear for the next group peakgroup.clear(); } else { @@ -812,9 +810,7 @@ void LeBailFunction::groupPeaks( } } else { // Rightmost peak. Finish the current peak - vector<pair<double, IPowderDiffPeakFunction_sptr>> peakgroupcopy = - peakgroup; - peakgroupvec.push_back(peakgroupcopy); + peakgroupvec.push_back(peakgroup); } ++ipk; @@ -827,17 +823,14 @@ void LeBailFunction::groupPeaks( << "peak over at maximum TOF = " << xmax << ".\n"; if (!peakgroup.empty()) { - vector<pair<double, IPowderDiffPeakFunction_sptr>> peakgroupcopy = - peakgroup; - peakgroupvec.push_back(peakgroupcopy); + peakgroupvec.push_back(peakgroup); } } // FIRST out of boundary } // ENDWHILE while (ipk < m_numPeaks) { // Group peaks out of uppper boundary to a separate vector of peaks - IPowderDiffPeakFunction_sptr thispeak = m_dspPeakVec[ipk].second; - outboundpeakvec.push_back(thispeak); + outboundpeakvec.push_back(m_dspPeakVec[ipk].second); ipk += 1; } diff --git a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp index 415298121a8..4eb75a48b86 100644 --- a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp +++ b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp @@ -636,7 +636,7 @@ std::string PlotPeakByLogValue::getMinimizerString(const std::string &wsName, Mantid::API::WorkspaceProperty<> *wsProp = dynamic_cast<Mantid::API::WorkspaceProperty<> *>(minimizerProp); if (wsProp) { - std::string wsPropValue = minimizerProp->value(); + const std::string &wsPropValue = minimizerProp->value(); if (wsPropValue != "") { std::string wsPropName = minimizerProp->name(); m_minimizerWorkspaces[wsPropName].push_back(wsPropValue); diff --git a/Framework/DataHandling/src/ImggAggregateWavelengths.cpp b/Framework/DataHandling/src/ImggAggregateWavelengths.cpp index 3b8d5948b6a..52b42d4114f 100644 --- a/Framework/DataHandling/src/ImggAggregateWavelengths.cpp +++ b/Framework/DataHandling/src/ImggAggregateWavelengths.cpp @@ -558,7 +558,7 @@ ImggAggregateWavelengths::findInputSubdirs(const Poco::Path &path) { // there is at least one image file: take just the first level directory if (it->isFile()) { - const std::string name = it.name(); + const std::string &name = it.name(); const std::string extShort = name.substr(name.size() - 3); const std::string extLong = name.substr(name.size() - 4); diff --git a/Framework/DataHandling/src/Load.cpp b/Framework/DataHandling/src/Load.cpp index aca068f9239..188508e429f 100644 --- a/Framework/DataHandling/src/Load.cpp +++ b/Framework/DataHandling/src/Load.cpp @@ -245,7 +245,7 @@ void Load::declareLoaderProperties(const API::IAlgorithm_sptr &loader) { // THIS IS A COPY as the properties are mutated as we move through them const std::vector<Property *> existingProps = this->getProperties(); for (auto existingProp : existingProps) { - const std::string name = existingProp->name(); + const std::string &name = existingProp->name(); // Wipe all properties except the Load native ones if (m_baseProps.find(name) == m_baseProps.end()) { this->removeProperty(name); diff --git a/Framework/DataHandling/src/LoadEventNexus.cpp b/Framework/DataHandling/src/LoadEventNexus.cpp index eb8d8b5b874..e3234005c82 100644 --- a/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Framework/DataHandling/src/LoadEventNexus.cpp @@ -1940,8 +1940,7 @@ void LoadEventNexus::runLoadMonitorsAsEvents(API::Progress *const prog) { << "data workspace.\n"; try { auto to = m_ws->getSingleHeldWorkspace(); - auto from = dataWS; - copyLogs(from, to); + copyLogs(dataWS, to); g_log.information() << "Log data copied.\n"; } catch (std::runtime_error &) { g_log.error() diff --git a/Framework/DataHandling/src/LoadFITS.cpp b/Framework/DataHandling/src/LoadFITS.cpp index a941b625844..282cd4e74df 100644 --- a/Framework/DataHandling/src/LoadFITS.cpp +++ b/Framework/DataHandling/src/LoadFITS.cpp @@ -472,19 +472,17 @@ void LoadFITS::doLoadFiles(const std::vector<std::string> &paths, // Create a group for these new workspaces, if the group already exists, add // to it. - std::string groupName = outWSName; - size_t fileNumberInGroup = 0; WorkspaceGroup_sptr wsGroup; - if (!AnalysisDataService::Instance().doesExist(groupName)) { - wsGroup = WorkspaceGroup_sptr(new WorkspaceGroup()); - wsGroup->setTitle(groupName); + if (!AnalysisDataService::Instance().doesExist(outWSName)) { + wsGroup = boost::make_shared<WorkspaceGroup>(); + wsGroup->setTitle(outWSName); } else { // Get the name of the latest file in group to start numbering from - if (AnalysisDataService::Instance().doesExist(groupName)) + if (AnalysisDataService::Instance().doesExist(outWSName)) wsGroup = - AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(groupName); + AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(outWSName); std::string latestName = wsGroup->getNames().back(); // Set next file number diff --git a/Framework/DataHandling/src/LoadInstrument.cpp b/Framework/DataHandling/src/LoadInstrument.cpp index 62d8c1a9269..7a6dfe77acd 100644 --- a/Framework/DataHandling/src/LoadInstrument.cpp +++ b/Framework/DataHandling/src/LoadInstrument.cpp @@ -270,7 +270,7 @@ std::string LoadInstrument::getFullPathParamIDF(std::string directoryName) { directoryPath.makeDirectory(); // Remove the path from the filename Poco::Path filePath(m_filename); - std::string instrumentFile = filePath.getFileName(); + const std::string &instrumentFile = filePath.getFileName(); // First check whether there is a parameter file whose name is the same as the // IDF file, diff --git a/Framework/DataHandling/src/LoadNXcanSAS.cpp b/Framework/DataHandling/src/LoadNXcanSAS.cpp index 993bb6f8a0a..5fe552975b1 100644 --- a/Framework/DataHandling/src/LoadNXcanSAS.cpp +++ b/Framework/DataHandling/src/LoadNXcanSAS.cpp @@ -131,7 +131,7 @@ std::string extractIdfFileOnCurrentSystem(std::string idf) { // Get the specified IDF name Poco::Path path(idf); - auto fileName = path.getFileName(); + const auto &fileName = path.getFileName(); // Compare against all available IDFs const std::vector<std::string> &directoryNames = diff --git a/Framework/DataHandling/src/SaveGSS.cpp b/Framework/DataHandling/src/SaveGSS.cpp index fa9c252fb9e..4c3668e1f5b 100644 --- a/Framework/DataHandling/src/SaveGSS.cpp +++ b/Framework/DataHandling/src/SaveGSS.cpp @@ -160,8 +160,7 @@ void SaveGSS::exec() { // Check whether append or not if (!split) { - const std::string file(filename); - Poco::File fileobj(file); + Poco::File fileobj(filename); if (fileobj.exists() && !append) { // Non-append mode and will be overwritten g_log.warning() << "Target GSAS file " << filename diff --git a/Framework/DataObjects/inc/MantidDataObjects/VectorColumn.h b/Framework/DataObjects/inc/MantidDataObjects/VectorColumn.h index 2833c272232..26c868a2bc3 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/VectorColumn.h +++ b/Framework/DataObjects/inc/MantidDataObjects/VectorColumn.h @@ -80,8 +80,7 @@ public: Mantid::Kernel::StringTokenizer elements( text, ",", Mantid::Kernel::StringTokenizer::TOK_TRIM); - for (const auto &it : elements) { - std::string element(it); + for (const auto &element : elements) { try { newValues.push_back(boost::lexical_cast<Type>(element)); } catch (boost::bad_lexical_cast &) { diff --git a/Framework/Geometry/src/Crystal/CompositeBraggScatterer.cpp b/Framework/Geometry/src/Crystal/CompositeBraggScatterer.cpp index c36f94ac250..3e49afd8588 100644 --- a/Framework/Geometry/src/Crystal/CompositeBraggScatterer.cpp +++ b/Framework/Geometry/src/Crystal/CompositeBraggScatterer.cpp @@ -186,7 +186,7 @@ void CompositeBraggScatterer::redeclareProperties() { std::vector<Property *> properties = scatterer->getPropertiesInGroup(getPropagatingGroupName()); for (auto &property : properties) { - std::string propertyName = property->name(); + const std::string &propertyName = property->name(); if (!existsProperty(propertyName)) { declareProperty(std::unique_ptr<Property>(property->clone())); } diff --git a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp index ad4df158955..51dd5abb109 100644 --- a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp +++ b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp @@ -753,7 +753,7 @@ Poco::XML::Element *InstrumentDefinitionParser::getParentComponent( const Poco::XML::Element *pLocElem) { if ((pLocElem->tagName()).compare("location") && (pLocElem->tagName()).compare("locations")) { - std::string tagname = pLocElem->tagName(); + const std::string &tagname = pLocElem->tagName(); g_log.error("Argument to function getParentComponent must be a pointer to " "an XML element with tag name location or locations."); throw std::logic_error( diff --git a/Framework/Kernel/src/InstrumentInfo.cpp b/Framework/Kernel/src/InstrumentInfo.cpp index 932712b4439..7e3cda977f9 100644 --- a/Framework/Kernel/src/InstrumentInfo.cpp +++ b/Framework/Kernel/src/InstrumentInfo.cpp @@ -205,7 +205,7 @@ void InstrumentInfo::fillTechniques(const Poco::XML::Element *elem) { if (pNL->length() > 0) { Poco::XML::Text *txt = dynamic_cast<Poco::XML::Text *>(pNL->item(0)); if (txt) { - std::string tech = txt->getData(); + const std::string &tech = txt->getData(); if (!tech.empty()) { m_technique.insert(tech); } diff --git a/Framework/LiveData/src/SNSLiveEventDataListener.cpp b/Framework/LiveData/src/SNSLiveEventDataListener.cpp index a3a2a57bb7e..a24f2cf1b16 100644 --- a/Framework/LiveData/src/SNSLiveEventDataListener.cpp +++ b/Framework/LiveData/src/SNSLiveEventDataListener.cpp @@ -1198,7 +1198,7 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::AnnotationPkt &pkt) { } // mutex auto unlocks here // if there's a comment in the packet, log it at the info level - std::string comment = pkt.comment(); + const std::string &comment = pkt.comment(); if (comment.size() > 0) { g_log.information() << "Annotation: " << comment << '\n'; } diff --git a/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp b/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp index 4223a88d247..e11d0a2a9c9 100644 --- a/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp +++ b/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp @@ -178,8 +178,7 @@ void CompareMDWorkspaces::compareMDHistoWorkspaces( */ template <typename MDE, size_t nd> void CompareMDWorkspaces::compareMDWorkspaces( - typename MDEventWorkspace<MDE, nd>::sptr ws) { - typename MDEventWorkspace<MDE, nd>::sptr ws1 = ws; + typename MDEventWorkspace<MDE, nd>::sptr ws1) { typename MDEventWorkspace<MDE, nd>::sptr ws2 = boost::dynamic_pointer_cast<MDEventWorkspace<MDE, nd>>(inWS2); if (!ws1 || !ws2) diff --git a/Framework/MDAlgorithms/src/LoadILLAscii.cpp b/Framework/MDAlgorithms/src/LoadILLAscii.cpp index e5cb0a709f1..589437c2d67 100644 --- a/Framework/MDAlgorithms/src/LoadILLAscii.cpp +++ b/Framework/MDAlgorithms/src/LoadILLAscii.cpp @@ -270,7 +270,7 @@ IMDEventWorkspace_sptr LoadILLAscii::mergeWorkspaces( std::vector<API::MatrixWorkspace_sptr> &workspaceList) { Poco::TemporaryFile tmpFile; - std::string tempFileName = tmpFile.path(); + const std::string &tempFileName = tmpFile.path(); g_log.debug() << "Dumping WSs in a temp file: " << tempFileName << '\n'; std::ofstream myfile; diff --git a/Framework/MDAlgorithms/src/MergeMD.cpp b/Framework/MDAlgorithms/src/MergeMD.cpp index bdcfb08fa19..196133dd0b3 100644 --- a/Framework/MDAlgorithms/src/MergeMD.cpp +++ b/Framework/MDAlgorithms/src/MergeMD.cpp @@ -162,11 +162,10 @@ void MergeMD::createOutputWorkspace(std::vector<std::string> &inputs) { * @param ws :: MDEventWorkspace to clone */ template <typename MDE, size_t nd> -void MergeMD::doPlus(typename MDEventWorkspace<MDE, nd>::sptr ws) { +void MergeMD::doPlus(typename MDEventWorkspace<MDE, nd>::sptr ws2) { // CPUTimer tim; typename MDEventWorkspace<MDE, nd>::sptr ws1 = boost::dynamic_pointer_cast<MDEventWorkspace<MDE, nd>>(out); - typename MDEventWorkspace<MDE, nd>::sptr ws2 = ws; if (!ws1 || !ws2) throw std::runtime_error("Incompatible workspace types passed to MergeMD."); diff --git a/Framework/MDAlgorithms/src/MinusMD.cpp b/Framework/MDAlgorithms/src/MinusMD.cpp index 91d846e94bf..c0c2cb8e91a 100644 --- a/Framework/MDAlgorithms/src/MinusMD.cpp +++ b/Framework/MDAlgorithms/src/MinusMD.cpp @@ -51,8 +51,7 @@ void MinusMD::checkInputs() { * @param ws :: MDEventWorkspace being added to */ template <typename MDE, size_t nd> -void MinusMD::doMinus(typename MDEventWorkspace<MDE, nd>::sptr ws) { - typename MDEventWorkspace<MDE, nd>::sptr ws1 = ws; +void MinusMD::doMinus(typename MDEventWorkspace<MDE, nd>::sptr ws1) { typename MDEventWorkspace<MDE, nd>::sptr ws2 = boost::dynamic_pointer_cast<MDEventWorkspace<MDE, nd>>(m_operand_event); if (!ws1 || !ws2) diff --git a/Framework/MDAlgorithms/src/PlusMD.cpp b/Framework/MDAlgorithms/src/PlusMD.cpp index 3beb2ec6044..1fbe4b1d6b0 100644 --- a/Framework/MDAlgorithms/src/PlusMD.cpp +++ b/Framework/MDAlgorithms/src/PlusMD.cpp @@ -25,8 +25,7 @@ DECLARE_ALGORITHM(PlusMD) * @param ws :: MDEventWorkspace being added to */ template <typename MDE, size_t nd> -void PlusMD::doPlus(typename MDEventWorkspace<MDE, nd>::sptr ws) { - typename MDEventWorkspace<MDE, nd>::sptr ws1 = ws; +void PlusMD::doPlus(typename MDEventWorkspace<MDE, nd>::sptr ws1) { typename MDEventWorkspace<MDE, nd>::sptr ws2 = boost::dynamic_pointer_cast<MDEventWorkspace<MDE, nd>>(m_operand_event); if (!ws1 || !ws2) diff --git a/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp b/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp index 05d6ee29d07..3a820ca5160 100644 --- a/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp +++ b/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp @@ -251,20 +251,19 @@ void SlicingAlgorithm::makeBasisVectorFromString(const std::string &str) { double binningScaling = double(numBins) / (lengthInInput); // Extract the arguments - std::string id = name; std::string units = Strings::strip(strs[0]); // Create the appropriate frame auto frame = createMDFrameForNonAxisAligned(units, basis); // Create the output dimension - MDHistoDimension_sptr out( - new MDHistoDimension(name, id, *frame, static_cast<coord_t>(min), - static_cast<coord_t>(max), numBins)); + auto out = boost::make_shared<MDHistoDimension>( + name, name, *frame, static_cast<coord_t>(min), static_cast<coord_t>(max), + numBins); // Put both in the algo for future use m_bases.push_back(basis); - m_binDimensions.push_back(out); + m_binDimensions.push_back(std::move(out)); m_binningScaling.push_back(binningScaling); m_transformScaling.push_back(transformScaling); } @@ -430,8 +429,7 @@ void SlicingAlgorithm::createGeneralTransform() { if (m_outD == inD) { // Can't reverse transform if you lost dimensions. auto ctTo = new DataObjects::CoordTransformAffine(inD, m_outD); - Matrix<coord_t> fromMatrix = ctFrom->getMatrix(); - Matrix<coord_t> toMatrix = fromMatrix; + Matrix<coord_t> toMatrix = ctFrom->getMatrix(); // Invert the affine matrix to get the reverse transformation toMatrix.Invert(); ctTo->setMatrix(toMatrix); diff --git a/Framework/RemoteAlgorithms/src/SCARFTomoReconstruction.cpp b/Framework/RemoteAlgorithms/src/SCARFTomoReconstruction.cpp index 4b95f5de96a..bc78aa0f4d7 100644 --- a/Framework/RemoteAlgorithms/src/SCARFTomoReconstruction.cpp +++ b/Framework/RemoteAlgorithms/src/SCARFTomoReconstruction.cpp @@ -1348,12 +1348,11 @@ void SCARFTomoReconstruction::getOneJobFile(const std::string &jobId, {"Content-Type", "application/xml"}, {"Cookie", token}, {"Accept", m_acceptType}}; - std::string body = remotePath; int code; std::stringstream ss; try { - code = doSendRequestGetResponse(httpsURL, ss, headers, - Poco::Net::HTTPRequest::HTTP_GET, body); + code = doSendRequestGetResponse( + httpsURL, ss, headers, Poco::Net::HTTPRequest::HTTP_GET, remotePath); } catch (Kernel::Exception::InternetError &ie) { throw std::runtime_error( "Error while sending HTTP request to download a file: " + diff --git a/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp b/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp index ba53b73cd36..beb5de2fe48 100644 --- a/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp +++ b/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp @@ -369,8 +369,7 @@ std::string MantidWebServiceAPIJobManager::startRemoteTransaction() { * (remote) compute resource. */ void MantidWebServiceAPIJobManager::stopRemoteTransaction( - const std::string &transactionID) { - std::string transId = transactionID; + const std::string &transId) { std::istream &respStream = httpGet("/transaction", std::string("Action=Stop&TransID=") + transId); @@ -420,9 +419,8 @@ std::string MantidWebServiceAPIJobManager::submitRemoteJob( postData[runnable] = param; // Job name is optional - std::string jobName = taskName; - if (jobName.length() > 0) { - postData["JobName"] = jobName; + if (taskName.length() > 0) { + postData["JobName"] = taskName; } std::istream &respStream = httpPost("/submit", postData); -- GitLab