From e7357c1a994465a57f26a60518f694d00a4b4628 Mon Sep 17 00:00:00 2001 From: berniev Date: Fri, 5 Aug 2022 16:04:34 +1000 Subject: [PATCH] App: use emplace_back --- src/App/Application.cpp | 16 ++++++++-------- src/App/ColorModel.cpp | 6 +++--- src/App/Document.cpp | 2 +- src/App/DocumentObjectPyImp.cpp | 4 ++-- src/App/Expression.cpp | 2 +- src/App/Link.cpp | 10 +++++----- src/App/PropertyExpressionEngine.cpp | 4 ++-- src/App/PropertyLinks.cpp | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index ce4d51968a..019aab6390 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -441,7 +441,7 @@ Document* Application::newDocument(const char * Name, const char * UserName, boo names.reserve(DocMap.size()); std::map::const_iterator pos; for (pos = DocMap.begin();pos != DocMap.end();++pos) { - names.push_back(pos->second->Label.getValue()); + names.emplace_back(pos->second->Label.getValue()); } if (!names.empty()) @@ -601,9 +601,9 @@ int Application::addPendingDocument(const char *FileName, const char *objName, b if(!_docReloadAttempts[FileName].emplace(objName).second) return -1; auto ret = _pendingDocMap.emplace(FileName,std::vector()); - ret.first->second.push_back(objName); + ret.first->second.emplace_back(objName); if(ret.second) { - _pendingDocs.push_back(ret.first->first.c_str()); + _pendingDocs.emplace_back(ret.first->first.c_str()); return 1; } return -1; @@ -717,7 +717,7 @@ std::vector Application::openDocuments(const std::vector _allowPartial = !hGrp->GetBool("NoPartialLoading",false); for (auto &name : filenames) - _pendingDocs.push_back(name.c_str()); + _pendingDocs.emplace_back(name.c_str()); std::map timings; @@ -853,7 +853,7 @@ std::vector Application::openDocuments(const std::vector FC_TIME_INIT(t1); // Finalize document restoring with the correct order if(doc->afterRestore(true)) { - openedDocs.push_back(doc); + openedDocs.emplace_back(doc); it = docs.erase(it); } else { ++it; @@ -864,7 +864,7 @@ std::vector Application::openDocuments(const std::vector // 'touched' object requires recomputation. And an object may // become touched during restoring if externally linked // document time stamp mismatches with the stamp saved. - _pendingDocs.push_back(doc->FileName.getValue()); + _pendingDocs.emplace_back(doc->FileName.getValue()); _pendingDocMap.erase(doc->FileName.getValue()); } FC_DURATION_PLUS(timing.d2,t1); @@ -937,7 +937,7 @@ Document* Application::openDocumentPrivate(const char * FileName, // close and reopen the document immediately here, but // add it to _pendingDocsReopen to delay reloading. for(auto obj : doc->getObjects()) - objNames.push_back(obj->getNameInDocument()); + objNames.emplace_back(obj->getNameInDocument()); _pendingDocMap[doc->FileName.getValue()] = std::move(objNames); break; } @@ -2205,7 +2205,7 @@ void parseProgramOptions(int ac, char ** av, const string& exe, variables_map& v args.back() += av[i]; } else { - args.push_back(av[i]); + args.emplace_back(av[i]); } if (strcmp(av[i],"-style") == 0) { merge = true; diff --git a/src/App/ColorModel.cpp b/src/App/ColorModel.cpp index fc6cb5c78c..d2647b7cf6 100644 --- a/src/App/ColorModel.cpp +++ b/src/App/ColorModel.cpp @@ -328,9 +328,9 @@ ColorLegend::ColorLegend () colorFields.emplace_back(0, 1, 0); colorFields.emplace_back(1, 0, 0); - names.push_back("Min"); - names.push_back("Mid"); - names.push_back("Max"); + names.emplace_back("Min"); + names.emplace_back("Mid"); + names.emplace_back("Max"); values.push_back(-1.0f); values.push_back(-0.333f); diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 5fc3ebf4f4..8602487eb5 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -2020,7 +2020,7 @@ Document::readObjects(Base::XMLReader& reader) std::vector objs; objs.reserve(d->partialLoadObjects.size()); for(auto &v : d->partialLoadObjects) - objs.push_back(v.first.c_str()); + objs.emplace_back(v.first.c_str()); for(auto &name : objs) _loadDeps(name,d->partialLoadObjects,deps); if(Cnt > (int)d->partialLoadObjects.size()) diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index bc1ab00426..bf409ba338 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -448,7 +448,7 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds) bool single = true; if (PyUnicode_Check(obj)) { - subs.push_back(PyUnicode_AsUTF8(obj)); + subs.emplace_back(PyUnicode_AsUTF8(obj)); } else if (PySequence_Check(obj)) { single = false; @@ -456,7 +456,7 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds) for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) { PyObject* item = (*it).ptr(); if (PyUnicode_Check(item)) { - subs.push_back(PyUnicode_AsUTF8(item)); + subs.emplace_back(PyUnicode_AsUTF8(item)); } else { PyErr_SetString(PyExc_TypeError, "non-string object in sequence"); diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index 5463d0c7eb..76f365ea7e 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -3284,7 +3284,7 @@ std::vector > tokenize(const std::string &str) column = 0; try { while ( (token = ExpressionParserlex()) != 0) - result.push_back(std::make_tuple(token, ExpressionParser::last_column, yytext)); + result.emplace_back(token, ExpressionParser::last_column, yytext); } catch (...) { // Ignore all exceptions diff --git a/src/App/Link.cpp b/src/App/Link.cpp index 28ce92a9ee..b0ca3ecaae 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -906,7 +906,7 @@ void LinkBaseExtension::monitorOnChangeCopyObjects( return; for(auto obj : objs) { obj->setStatus(App::ObjectStatus::TouchOnColorChange, true); - copyOnChangeSrcConns.push_back(obj->signalChanged.connect( + copyOnChangeSrcConns.emplace_back(obj->signalChanged.connect( [this](const DocumentObject &, const Property &) { if (auto prop = this->getLinkCopyOnChangeTouchedProperty()) { if (this->getLinkCopyOnChangeValue() != CopyOnChangeDisabled) @@ -1247,7 +1247,7 @@ bool LinkBaseExtension::extensionGetSubObjects(std::vector &ret, in char index[30]; for(int i=0,count=_getElementCountValue();i objs; for (auto obj : getElementListValue()) - objs.push_back(obj); + objs.emplace_back(obj); getElementListProperty()->setValue(); for(const auto &objT : objs) detachElement(objT.getObject()); diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index c1063c4192..d13c8c6b62 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -181,10 +181,10 @@ void PropertyExpressionEngine::hasSetValue() auto &propDeps = pimpl->propMap[key]; if(propDeps.empty()) { if(propName.size()) - pimpl->conns.push_back(obj->signalChanged.connect(boost::bind( + pimpl->conns.emplace_back(obj->signalChanged.connect(boost::bind( &PropertyExpressionEngine::slotChangedProperty,this,_1,_2))); else - pimpl->conns.push_back(obj->signalChanged.connect(boost::bind( + pimpl->conns.emplace_back(obj->signalChanged.connect(boost::bind( &PropertyExpressionEngine::slotChangedObject,this,_1,_2))); } propDeps.push_back(e.first); diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index e1e213f993..789bd51f69 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -4328,7 +4328,7 @@ void PropertyXLinkSubList::getLinks(std::vector &objs, if(obj && obj->getNameInDocument()) { auto subnames = l.getSubValues(newStyle); if (subnames.empty()) - subnames.push_back(""); + subnames.emplace_back(""); for(auto &sub : subnames) { objs.push_back(obj); subs->push_back(std::move(sub));