Commit 24bdf433 authored by Nick Draper's avatar Nick Draper
Browse files

Change push_back to emplace_back where possible

re #27319
parent 0993721b
......@@ -69,9 +69,9 @@ void Algorithm::declareWorkspaceInputProperties(const std::string &propertyName,
"index type; Indices are entered as a comma-separated list "
"of values, and/or ranges; For example, '4,6,10-20,1000';");
m_reservedList.push_back(propertyName);
m_reservedList.push_back(indexTypePropName);
m_reservedList.push_back(indexPropName);
m_reservedList.emplace_back(propertyName);
m_reservedList.emplace_back(indexTypePropName);
m_reservedList.emplace_back(indexPropName);
}
template <typename T1, typename T2, typename WsType>
......
......@@ -327,7 +327,7 @@ std::vector<std::string> WorkspaceProperty<TYPE>::allowedValues() const {
Mantid::Kernel::DataServiceSort::Sorted);
if (isOptional()) // Insert an empty option
{
vals.push_back("");
vals.emplace_back("");
}
// Copy-construct a temporary workspace property to test the validity of
// each workspace
......
......@@ -74,7 +74,7 @@ std::vector<std::string> ADSValidator::allowedValues() const {
Mantid::Kernel::DataServiceSort::Sorted);
if (isOptional()) // Insert an empty option
{
vals.push_back("");
vals.emplace_back("");
}
return vals;
}
......
......@@ -321,15 +321,15 @@ void Algorithm::cacheWorkspaceProperties() {
continue;
switch (prop->direction()) {
case Kernel::Direction::Input:
m_inputWorkspaceProps.push_back(wsProp);
m_inputWorkspaceProps.emplace_back(wsProp);
break;
case Kernel::Direction::InOut:
m_inputWorkspaceProps.push_back(wsProp);
m_outputWorkspaceProps.push_back(wsProp);
m_inputWorkspaceProps.emplace_back(wsProp);
m_outputWorkspaceProps.emplace_back(wsProp);
break;
case Kernel::Direction::Output:
m_outputWorkspaceProps.push_back(wsProp);
m_pureOutputWorkspaceProps.push_back(wsProp);
m_outputWorkspaceProps.emplace_back(wsProp);
m_pureOutputWorkspaceProps.emplace_back(wsProp);
break;
default:
throw std::logic_error(
......@@ -433,7 +433,7 @@ void Algorithm::lockWorkspaces() {
// Write-lock it if not already
debugLog << "Write-locking " << ws->getName() << '\n';
ws->getLock()->writeLock();
m_writeLockedWorkspaces.push_back(ws);
m_writeLockedWorkspaces.emplace_back(ws);
}
}
}
......@@ -451,7 +451,7 @@ void Algorithm::lockWorkspaces() {
// Read-lock it if not already write-locked
debugLog << "Read-locking " << ws->getName() << '\n';
ws->getLock()->readLock();
m_readLockedWorkspaces.push_back(ws);
m_readLockedWorkspaces.emplace_back(ws);
}
}
}
......@@ -773,7 +773,7 @@ void Algorithm::store() {
throw;
}
} else {
groupWsIndicies.push_back(i);
groupWsIndicies.emplace_back(i);
}
}
}
......@@ -870,7 +870,7 @@ void Algorithm::setupAsChildAlgorithm(Algorithm_sptr alg,
// in parallel safely.
boost::weak_ptr<IAlgorithm> weakPtr(alg);
PARALLEL_CRITICAL(Algorithm_StoreWeakPtr) {
m_ChildAlgorithms.push_back(weakPtr);
m_ChildAlgorithms.emplace_back(weakPtr);
}
}
......@@ -1390,7 +1390,7 @@ bool Algorithm::processGroups() {
auto *prop = dynamic_cast<Property *>(pureOutputWorkspaceProp);
if (prop && !prop->value().empty()) {
auto outWSGrp = boost::make_shared<WorkspaceGroup>();
outGroups.push_back(outWSGrp);
outGroups.emplace_back(outWSGrp);
// Put the GROUP in the ADS
AnalysisDataService::Instance().addOrReplace(prop->value(), outWSGrp);
outWSGrp->observeADSNotifications(false);
......
......@@ -216,7 +216,7 @@ AlgorithmFactoryImpl::getKeys(bool includeHidden) const {
if (!toBeRemoved) {
// just mark them to be removed as we are iterating around the vector at
// the moment
validNames.push_back(name);
validNames.emplace_back(name);
}
}
return validNames;
......@@ -383,7 +383,7 @@ AlgorithmFactoryImpl::getDescriptors(bool includeHidden) const {
}
if (!categoryIsHidden)
res.push_back(desc);
res.emplace_back(desc);
}
}
return res;
......
......@@ -91,7 +91,7 @@ void AlgorithmHistory::setProperties(const Algorithm *const alg) {
// objects.
const std::vector<Property *> &properties = alg->getProperties();
for (const auto &property : properties) {
m_properties.push_back(
m_properties.emplace_back(
boost::make_shared<PropertyHistory>(property->createHistory()));
}
}
......@@ -147,7 +147,7 @@ void AlgorithmHistory::addExecutionInfo(const DateAndTime &start,
void AlgorithmHistory::addProperty(const std::string &name,
const std::string &value, bool isdefault,
const unsigned int &direction) {
m_properties.push_back(boost::make_shared<PropertyHistory>(
m_properties.emplace_back(boost::make_shared<PropertyHistory>(
name, value, "", isdefault, direction));
}
......
......@@ -112,7 +112,7 @@ IAlgorithm_sptr AlgorithmManagerImpl::create(const std::string &algName,
}
// Add to list of managed ones
m_managed_algs.push_back(alg);
m_managed_algs.emplace_back(alg);
alg->initialize();
} catch (std::runtime_error &ex) {
......
......@@ -144,7 +144,7 @@ void AlgorithmProxy::addObserver(const Poco::AbstractObserver &observer) const {
}
// save the observer in any case because m_alg can be reset (eg in
// createConcreteAlg())
m_externalObservers.push_back(obs);
m_externalObservers.emplace_back(obs);
}
/** Remove an observer.
......
......@@ -17,7 +17,7 @@ CompositeCatalog::CompositeCatalog() : m_catalogs() {}
* @param catalog :: The catalog to add to the container.
*/
void CompositeCatalog::add(const ICatalog_sptr catalog) {
m_catalogs.push_back(catalog);
m_catalogs.emplace_back(catalog);
}
/**
......
......@@ -403,13 +403,13 @@ void CompositeFunction::clear() {
*/
size_t CompositeFunction::addFunction(IFunction_sptr f) {
m_IFunction.insert(m_IFunction.end(), f->nParams(), m_functions.size());
m_functions.push_back(f);
m_functions.emplace_back(f);
//?f->init();
if (m_paramOffsets.empty()) {
m_paramOffsets.push_back(0);
m_paramOffsets.emplace_back(0);
m_nParams = f->nParams();
} else {
m_paramOffsets.push_back(m_nParams);
m_paramOffsets.emplace_back(m_nParams);
m_nParams += f->nParams();
}
return m_functions.size() - 1;
......@@ -828,14 +828,14 @@ CompositeFunction::createEquivalentFunctions() const {
std::vector<std::vector<IFunction_sptr>> equiv;
equiv.reserve(nf);
for (size_t i = 0; i < nf; ++i) {
equiv.push_back(getFunction(i)->createEquivalentFunctions());
equiv.emplace_back(getFunction(i)->createEquivalentFunctions());
}
std::vector<IFunction_sptr> funs;
funs.reserve(nd);
for (size_t i = 0; i < nd; ++i) {
auto comp = new CompositeFunction;
funs.push_back(IFunction_sptr(comp));
funs.emplace_back(IFunction_sptr(comp));
for (size_t j = 0; j < nf; ++j) {
comp->addFunction(equiv[j][i]);
}
......
......@@ -86,8 +86,8 @@ void DetectorSearcher::createDetectorCache() {
if (point.hasNaN() || up.coLinear(beam, pos))
continue;
points.push_back(point);
m_indexMap.push_back(pointNo);
points.emplace_back(point);
m_indexMap.emplace_back(pointNo);
}
// create KDtree of cached detector Q vectors
......
......@@ -205,7 +205,7 @@ void Expression::parse(const std::string &str) {
setFunct(*tkz.begin());
for (size_t i = 0; i <= m_tokens.size(); i++) {
m_terms.push_back(Expression(this));
m_terms.emplace_back(Expression(this));
Expression &t = m_terms.back();
if (i)
t.m_op = GetOp(i - 1);
......@@ -330,7 +330,7 @@ void Expression::tokenize() {
if (prec < min_prec)
min_prec = prec;
Token tok(is, i - 1, is1, prec);
tokens.push_back(tok);
tokens.emplace_back(tok);
is = is1;
}
......@@ -429,7 +429,7 @@ void Expression::setFunct(const std::string &name) {
m_funct = op;
Expression tmp(this);
tmp.parse(name.substr(op.size()));
m_terms.push_back(tmp);
m_terms.emplace_back(tmp);
return;
}
}
......@@ -473,7 +473,7 @@ void Expression::setFunct(const std::string &name) {
tmp.parse(args);
if (tmp.name() != EMPTY_EXPRESSION_NAME &&
(!tmp.isFunct() || tmp.name() != ",")) {
m_terms.push_back(tmp);
m_terms.emplace_back(tmp);
} else {
if (f.empty() && tmp.name() == ",") {
f = ",";
......
......@@ -392,7 +392,7 @@ FileFinderImpl::getArchiveSearch(const Kernel::FacilityInfo &facility) const {
for (const auto &facilityname : facility.archiveSearch()) {
g_log.debug() << "get archive search for the facility..." << facilityname
<< "\n";
archs.push_back(ArchiveSearchFactory::Instance().create(facilityname));
archs.emplace_back(ArchiveSearchFactory::Instance().create(facilityname));
}
}
return archs;
......@@ -485,7 +485,7 @@ std::string FileFinderImpl::findRun(const std::string &hintstr,
std::vector<std::string> uniqueExts;
uniqueExts.reserve(1 + exts.size() + extensions.size());
if (!extension.empty())
uniqueExts.push_back(extension);
uniqueExts.emplace_back(extension);
// If provided exts are empty, or useExtsOnly is false,
// we want to include facility exts as well
......@@ -530,7 +530,7 @@ void FileFinderImpl::getUniqueExtensions(
const auto searchItr =
std::find(uniqueExts.begin(), uniqueExts.end(), transformed);
if (searchItr == uniqueExts.end()) {
uniqueExts.push_back(transformed);
uniqueExts.emplace_back(transformed);
}
}
}
......@@ -613,7 +613,7 @@ FileFinderImpl::findRuns(const std::string &hintstr,
run.insert(0, "0");
std::string path = findRun(p1.first + run, exts, useExtsOnly);
if (!path.empty()) {
res.push_back(path);
res.emplace_back(path);
} else {
throw Kernel::Exception::NotFoundError("Unable to find file:", run);
}
......@@ -621,7 +621,7 @@ FileFinderImpl::findRuns(const std::string &hintstr,
} else {
std::string path = findRun(*h, exts, useExtsOnly);
if (!path.empty()) {
res.push_back(path);
res.emplace_back(path);
} else {
throw Kernel::Exception::NotFoundError("Unable to find file:", *h);
}
......
......@@ -59,7 +59,7 @@ void addExtension(const std::string &extension,
extensions.end())
return;
else
extensions.push_back(extension);
extensions.emplace_back(extension);
}
/**
......
......@@ -32,7 +32,7 @@ void FunctionDomainGeneral::addColumn(boost::shared_ptr<Column> column) {
"All columns must have the same size.");
}
m_columns.push_back(column);
m_columns.emplace_back(column);
}
/// Get i-th column.
......
......@@ -365,9 +365,9 @@ void FunctionFactoryImpl::addTie(IFunction_sptr fun,
std::vector<std::string> FunctionFactoryImpl::getFunctionNamesGUI() const {
auto allNames = getFunctionNames<IFunction1D>();
allNames.push_back("ProductFunction");
allNames.push_back("CompositeFunction");
allNames.push_back("Convolution");
allNames.emplace_back("ProductFunction");
allNames.emplace_back("CompositeFunction");
allNames.emplace_back("Convolution");
std::sort(allNames.begin(), allNames.end());
std::vector<std::string> names;
names.reserve(allNames.size());
......
......@@ -239,7 +239,7 @@ boost::shared_ptr<Grouping> GroupingLoader::getDummyGrouping() {
auto dummyGrouping = boost::make_shared<Mantid::API::Grouping>();
dummyGrouping->description = "Dummy grouping";
dummyGrouping->groupNames.emplace_back("all");
dummyGrouping->groups.push_back(all.str());
dummyGrouping->groups.emplace_back(all.str());
return dummyGrouping;
}
......@@ -258,14 +258,14 @@ Grouping::Grouping(ITableWorkspace_sptr table) {
// Convert to a range string, i.e. 1-5,6-8,9
std::string detectorRange = Kernel::Strings::toString(detectors);
this->groupNames.push_back(std::to_string(row + 1));
this->groups.push_back(detectorRange);
this->groupNames.emplace_back(std::to_string(row + 1));
this->groups.emplace_back(detectorRange);
}
// If we have 2 groups only - create a longitudinal pair
if (this->groups.size() == 2) {
this->pairNames.emplace_back("long");
this->pairAlphas.push_back(1.0);
this->pairAlphas.emplace_back(1.0);
this->pairs.emplace_back(0, 1);
}
}
......
......@@ -266,7 +266,7 @@ void IFunction::addTie(std::unique_ptr<ParameterTie> tie) {
}
}
if (!found) {
m_ties.push_back(std::move(tie));
m_ties.emplace_back(std::move(tie));
setParameterStatus(iPar, Tied);
}
}
......@@ -368,7 +368,7 @@ void IFunction::addConstraint(std::unique_ptr<IConstraint> ic) {
}
}
if (!found) {
m_constraints.push_back(std::move(ic));
m_constraints.emplace_back(std::move(ic));
}
}
......@@ -478,7 +478,7 @@ IFunction::writeToString(const std::string &parentLocalAttributesStr) const {
ostr << ',' << paramOut.str();
// Output non-default ties only.
if (getParameterStatus(i) == Fixed) {
ties.push_back(paramOut.str());
ties.emplace_back(paramOut.str());
}
}
......@@ -492,7 +492,7 @@ IFunction::writeToString(const std::string &parentLocalAttributesStr) const {
// collect the non-default ties
auto tiesString = writeTies();
if (!tiesString.empty()) {
ties.push_back(tiesString);
ties.emplace_back(tiesString);
}
// print the ties
if (!ties.empty()) {
......@@ -549,7 +549,7 @@ void IFunction::addConstraints(const std::string &str, bool isDefault) {
std::vector<std::string> IFunction::getParameterNames() const {
std::vector<std::string> out;
for (size_t i = 0; i < nParams(); ++i) {
out.push_back(parameterName(i));
out.emplace_back(parameterName(i));
}
return out;
}
......@@ -1583,7 +1583,7 @@ void IFunction::sortTies() {
}
orderedTieNodes.push_front(newNode);
} else {
orderedTieNodes.push_back(newNode);
orderedTieNodes.emplace_back(newNode);
}
}
for (auto &&node : orderedTieNodes) {
......
......@@ -135,9 +135,9 @@ const std::string IMDWorkspace::toString() const {
void IMDWorkspace::makeSinglePointWithNaN(std::vector<coord_t> &x,
std::vector<signal_t> &y,
std::vector<signal_t> &e) const {
x.push_back(0);
y.push_back(std::numeric_limits<signal_t>::quiet_NaN());
e.push_back(std::numeric_limits<signal_t>::quiet_NaN());
x.emplace_back(0);
y.emplace_back(std::numeric_limits<signal_t>::quiet_NaN());
e.emplace_back(std::numeric_limits<signal_t>::quiet_NaN());
}
//-----------------------------------------------------------------------------------------------
......@@ -170,14 +170,14 @@ IMDWorkspace::getLinePlot(const Mantid::Kernel::VMD &start,
// Coordinate along the line
VMD coord = start + step * double(i);
// Record the position along the line
line.x.push_back(static_cast<coord_t>(stepLength * double(i)));
line.x.emplace_back(static_cast<coord_t>(stepLength * double(i)));
signal_t yVal = this->getSignalAtCoord(coord.getBareArray(), normalize);
line.y.push_back(yVal);
line.e.push_back(0.0);
line.y.emplace_back(yVal);
line.e.emplace_back(0.0);
}
// And the last point
line.x.push_back((end - start).norm());
line.x.emplace_back((end - start).norm());
return line;
}
......
......@@ -12,9 +12,9 @@ IndexTypeProperty::IndexTypeProperty(const std::string &name,
const int indexType)
: PropertyWithValue<std::string>(name, "", Kernel::Direction::Input) {
if (indexType & IndexType::WorkspaceIndex)
m_allowedValues.push_back("WorkspaceIndex");
m_allowedValues.emplace_back("WorkspaceIndex");
if (indexType & IndexType::SpectrumNum)
m_allowedValues.push_back("SpectrumNumber");
m_allowedValues.emplace_back("SpectrumNumber");
if (m_allowedValues.empty())
throw std::invalid_argument("Argument indexType incorrectly specified");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment