App: use emplace_back

This commit is contained in:
berniev
2022-08-05 16:04:34 +10:00
committed by wwmayer
parent fce9a2fcfb
commit ac81a8380f
8 changed files with 23 additions and 23 deletions

View File

@@ -441,7 +441,7 @@ Document* Application::newDocument(const char * Name, const char * UserName, boo
names.reserve(DocMap.size());
std::map<string,Document*>::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<std::string>());
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<Document*> Application::openDocuments(const std::vector<std::string>
_allowPartial = !hGrp->GetBool("NoPartialLoading",false);
for (auto &name : filenames)
_pendingDocs.push_back(name.c_str());
_pendingDocs.emplace_back(name.c_str());
std::map<DocumentT, DocTiming> timings;
@@ -853,7 +853,7 @@ std::vector<Document*> Application::openDocuments(const std::vector<std::string>
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<Document*> Application::openDocuments(const std::vector<std::string>
// '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;

View File

@@ -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);

View File

@@ -2020,7 +2020,7 @@ Document::readObjects(Base::XMLReader& reader)
std::vector<std::string> 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())

View File

@@ -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");

View File

@@ -3284,7 +3284,7 @@ std::vector<std::tuple<int, int, std::string> > 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

View File

@@ -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<std::string> &ret, in
char index[30];
for(int i=0,count=_getElementCountValue();i<count;++i) {
snprintf(index,sizeof(index),"%d.",i);
ret.push_back(index);
ret.emplace_back(index);
}
}
}
@@ -1496,13 +1496,13 @@ void LinkBaseExtension::parseSubName() const {
mySubElements.emplace_back("");
return;
}
mySubElements.push_back(element);
mySubElements.emplace_back(element);
mySubName = std::string(subname,element-subname);
for(std::size_t i=1;i<subs.size();++i) {
auto &sub = subs[i];
element = Data::ComplexGeoData::findElementName(sub.c_str());
if(element && element[0] && boost::starts_with(sub,mySubName))
mySubElements.push_back(element);
mySubElements.emplace_back(element);
}
}
@@ -2109,7 +2109,7 @@ void LinkBaseExtension::detachElements()
{
std::vector<App::DocumentObjectT> objs;
for (auto obj : getElementListValue())
objs.push_back(obj);
objs.emplace_back(obj);
getElementListProperty()->setValue();
for(const auto &objT : objs)
detachElement(objT.getObject());

View File

@@ -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);

View File

@@ -4328,7 +4328,7 @@ void PropertyXLinkSubList::getLinks(std::vector<App::DocumentObject *> &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));