App: use emplace_back
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user