From e8092953424c4c077ca194edafe7d7aa2c7308c3 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 28 Aug 2022 15:42:57 +0200 Subject: [PATCH] App: replace some while loops with range-based for loops to increase readability --- src/App/Document.cpp | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index ea6f09fc68..45871cd5e1 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -443,17 +443,16 @@ void Document::exportGraphviz(std::ostream& out) const setGraphAttributes(obj); } - // Create subgraphs for all documentobjects that it depends on; it will depend on some property there - auto i = expressions.begin(); - while (i != expressions.end()) { - std::map deps; + // Create subgraphs for all document objects that it depends on; it will depend on some property there + for (const auto &expr : expressions) { + std::map deps; - i->second->getIdentifiers(deps); + expr.second->getIdentifiers(deps); - for(auto j=deps.begin(); j!=deps.end(); ++j) { - if(j->second) + for (const auto &dep : deps) { + if (dep.second) continue; - DocumentObject * o = j->first.getDocumentObject(); + DocumentObject * o = dep.first.getDocumentObject(); // Doesn't exist already? if (o && !GraphList[o]) { @@ -470,10 +469,8 @@ void Document::exportGraphviz(std::ostream& out) const GraphList[o] = &graph->create_subgraph(); setGraphAttributes(o); } - } } - ++i; } } } @@ -689,27 +686,23 @@ void Document::exportGraphviz(std::ostream& out) const std::set > existingEdges; // Add edges between properties - std::set::const_iterator j = objects.begin(); - while (j != objects.end()) { - const DocumentObject * docObj = *j; + for (const auto &docObj : objects) { // Add expressions and its dependencies auto expressions = docObj->ExpressionEngine.getExpressions(); - auto i = expressions.begin(); - - while (i != expressions.end()) { - std::map deps; - i->second->getIdentifiers(deps); + for (const auto &expr : expressions) { + std::map deps; + expr.second->getIdentifiers(deps); // Create subgraphs for all documentobjects that it depends on; it will depend on some property there - for(auto k=deps.begin(); k!=deps.end(); ++k) { - if(k->second) + for (const auto &dep : deps) { + if (dep.second) continue; - DocumentObject * depObjDoc = k->first.getDocumentObject(); + DocumentObject * depObjDoc = dep.first.getDocumentObject(); Edge edge; bool inserted; - tie(edge, inserted) = add_edge(GlobalVertexList[getId(i->first)], GlobalVertexList[getId(k->first)], DepList); + tie(edge, inserted) = add_edge(GlobalVertexList[getId(expr.first)], GlobalVertexList[getId(dep.first)], DepList); // Add this edge to the set of all expression generated edges existingEdges.insert(std::make_pair(docObj, depObjDoc)); @@ -718,9 +711,7 @@ void Document::exportGraphviz(std::ostream& out) const edgeAttrMap[edge]["arrowsize"] = "0.5"; edgeAttrMap[edge]["style"] = "dashed"; } - ++i; } - ++j; } ParameterGrp::handle depGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/DependencyGraph");