diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-25 14:51:35 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-25 14:52:02 +0300 |
commit | cec629ae425d3e2f37f1b0d7ecda84a4233e5438 (patch) | |
tree | 3e136dac808915da70a928792e8df607e81173c2 /source/blender/depsgraph/intern/depsgraph_debug.cc | |
parent | f83f7bb98848eb9d0c0a2fa773df985454a96690 (diff) |
Depsgraph: Simplify some loops using foreach()
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_debug.cc')
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_debug.cc | 85 |
1 files changed, 18 insertions, 67 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index efb3e330857..5d21effe0f6 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -55,6 +55,7 @@ extern "C" { #include "depsnode_component.h" #include "depsnode_operation.h" #include "depsgraph_intern.h" +#include "depsgraph_util_foreach.h" /* ****************** */ /* Graphviz Debugging */ @@ -1018,33 +1019,18 @@ bool DEG_debug_scene_relations_validate(Main *bmain, bool DEG_debug_consistency_check(Depsgraph *graph) { /* Validate links exists in both directions. */ - for (Depsgraph::OperationNodes::const_iterator it_op = graph->operations.begin(); - it_op != graph->operations.end(); - ++it_op) - { - OperationDepsNode *node = *it_op; - for (OperationDepsNode::Relations::const_iterator it_rel = node->outlinks.begin(); - it_rel != node->outlinks.end(); - ++it_rel) - { - DepsRelation *rel = *it_rel; - + foreach (OperationDepsNode *node, graph->operations) { + foreach (DepsRelation *rel, node->outlinks) { int counter1 = 0; - for (OperationDepsNode::Relations::const_iterator tmp_rel = node->outlinks.begin(); - tmp_rel != node->outlinks.end(); - ++tmp_rel) - { - if (*tmp_rel == rel) { + foreach (DepsRelation *tmp_rel, node->outlinks) { + if (tmp_rel == rel) { ++counter1; } } int counter2 = 0; - for (OperationDepsNode::Relations::const_iterator tmp_rel = rel->to->inlinks.begin(); - tmp_rel != rel->to->inlinks.end(); - ++tmp_rel) - { - if (*tmp_rel == rel) { + foreach (DepsRelation *tmp_rel, rel->to->inlinks) { + if (tmp_rel == rel) { ++counter2; } } @@ -1057,33 +1043,18 @@ bool DEG_debug_consistency_check(Depsgraph *graph) } } - for (Depsgraph::OperationNodes::const_iterator it_op = graph->operations.begin(); - it_op != graph->operations.end(); - ++it_op) - { - OperationDepsNode *node = *it_op; - for (OperationDepsNode::Relations::const_iterator it_rel = node->inlinks.begin(); - it_rel != node->inlinks.end(); - ++it_rel) - { - DepsRelation *rel = *it_rel; - + foreach (OperationDepsNode *node, graph->operations) { + foreach (DepsRelation *rel, node->inlinks) { int counter1 = 0; - for (OperationDepsNode::Relations::const_iterator tmp_rel = node->inlinks.begin(); - tmp_rel != node->inlinks.end(); - ++tmp_rel) - { - if (*tmp_rel == rel) { + foreach (DepsRelation *tmp_rel, node->inlinks) { + if (tmp_rel == rel) { ++counter1; } } int counter2 = 0; - for (OperationDepsNode::Relations::const_iterator tmp_rel = rel->from->outlinks.begin(); - tmp_rel != rel->from->outlinks.end(); - ++tmp_rel) - { - if (*tmp_rel == rel) { + foreach (DepsRelation *tmp_rel, rel->from->outlinks) { + if (tmp_rel == rel) { ++counter2; } } @@ -1096,30 +1067,18 @@ bool DEG_debug_consistency_check(Depsgraph *graph) } /* Validate node valency calculated in both directions. */ - for (Depsgraph::OperationNodes::const_iterator it_op = graph->operations.begin(); - it_op != graph->operations.end(); - ++it_op) - { - OperationDepsNode *node = *it_op; + foreach (OperationDepsNode *node, graph->operations) { node->num_links_pending = 0; node->done = 0; } - for (Depsgraph::OperationNodes::const_iterator it_op = graph->operations.begin(); - it_op != graph->operations.end(); - ++it_op) - { - OperationDepsNode *node = *it_op; + foreach (OperationDepsNode *node, graph->operations) { if (node->done) { printf("Node %s is twice in the operations!\n", node->identifier().c_str()); return false; } - for (OperationDepsNode::Relations::const_iterator it_rel = node->outlinks.begin(); - it_rel != node->outlinks.end(); - ++it_rel) - { - DepsRelation *rel = *it_rel; + foreach (DepsRelation *rel, node->outlinks) { if (rel->to->type == DEPSNODE_TYPE_OPERATION) { OperationDepsNode *to = (OperationDepsNode *)rel->to; BLI_assert(to->num_links_pending < to->inlinks.size()); @@ -1129,17 +1088,9 @@ bool DEG_debug_consistency_check(Depsgraph *graph) node->done = 1; } - for (Depsgraph::OperationNodes::const_iterator it_op = graph->operations.begin(); - it_op != graph->operations.end(); - ++it_op) - { - OperationDepsNode *node = *it_op; + foreach (OperationDepsNode *node, graph->operations) { int num_links_pending = 0; - for (OperationDepsNode::Relations::const_iterator it_rel = node->inlinks.begin(); - it_rel != node->inlinks.end(); - ++it_rel) - { - DepsRelation *rel = *it_rel; + foreach (DepsRelation *rel, node->inlinks) { if (rel->from->type == DEPSNODE_TYPE_OPERATION) { ++num_links_pending; } |