]> granicus.if.org Git - graphviz/commitdiff
take a reference instead of a pointer in Blocks::dfsVisit
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 12 Jun 2021 19:29:13 +0000 (12:29 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 19 Jun 2021 19:24:07 +0000 (12:24 -0700)
This function has no ability to deal with being passed null, so it is cleaner to
accept a reference.

lib/vpsc/blocks.cpp
lib/vpsc/blocks.h

index a41a3e016c741cfac73f650c6976771a0dbe925b..47ae790e613f8bf260aac3dae851da785826eefc 100644 (file)
@@ -61,14 +61,14 @@ list<Variable*> *Blocks::totalOrder() {
        }
        for(int i=0;i<nvs;i++) {
                if(vs[i]->in.empty()) {
-                       dfsVisit(vs[i],order);
+                       dfsVisit(vs[i],*order);
                }
        }
        return order;
 }
 // Recursive depth first search giving total order by pushing nodes in the DAG
 // onto the front of the list when we finish searching them
-void Blocks::dfsVisit(Variable *v, list<Variable*> *order) {
+void Blocks::dfsVisit(Variable *v, list<Variable*> &order) {
        v->visited=true;
        vector<Constraint*>::iterator it=v->out.begin();
        for(;it!=v->out.end();it++) {
@@ -81,7 +81,7 @@ void Blocks::dfsVisit(Variable *v, list<Variable*> *order) {
                ofstream f(LOGFILE,ios::app);
                f<<"  order="<<*v<<"\n";
        }
-       order->push_front(v);
+       order.push_front(v);
 }
 /**
  * Processes incoming constraints, most violated to least, merging with the
index 7c3af91ee208dc532ed28376e7dc77e48799af51..b5b5442368aca541984fc3008861634b26e5882b 100644 (file)
@@ -46,7 +46,7 @@ public:
        void cleanup();
        double cost();
 private:
-       void dfsVisit(Variable *v, std::list<Variable*> *order);
+       void dfsVisit(Variable *v, std::list<Variable*> &order);
        void removeBlock(Block *doomed);
        Variable **vs;
        int nvs;