EFFICIENCY: If a new dependency overlaps with an old one, we don't have to recompute the closure.

This commit is contained in:
Cas Cremers 2010-11-10 23:58:59 +01:00
parent 6cd8007ab0
commit 01eb5854cf

View File

@ -74,7 +74,7 @@ extern Role I_M; //!< special role; precedes all other events always
* --------------------------------------------------------------- * ---------------------------------------------------------------
*/ */
Depeventgraph currentdepgraph; Depeventgraph currentdepgraph = NULL;
/* /*
* Default code * Default code
@ -497,27 +497,31 @@ dependPushEvent (const int r1, const int e1, const int r2, const int e2)
{ {
// change: make new graph copy of the old one // change: make new graph copy of the old one
dependPushGeneric (dependCopy (currentdepgraph)); dependPushGeneric (dependCopy (currentdepgraph));
// add new binding // really new?
setDependEvent (r1, e1, r2, e2); if (!isDependEvent (r1, e1, r2, e2))
// recompute closure
transitive_closure (currentdepgraph->G, currentdepgraph->n);
// check for cycles
if (hasCycle ())
{ {
//warning ("Cycle slipped undetected by the reverse check."); // add new binding
// Closure introduced cycle, undo it setDependEvent (r1, e1, r2, e2);
dependPopEvent (); // recompute closure
return false; transitive_closure (currentdepgraph->G, currentdepgraph->n);
} // check for cycles
if (hasCycle ())
{
//warning ("Cycle slipped undetected by the reverse check.");
// Closure introduced cycle, undo it
dependPopEvent ();
return false;
}
#ifdef DEBUG #ifdef DEBUG
debug (5, "Push dependGraph for new event (real push)\n"); debug (5, "Push dependGraph for new event (real push)\n");
if (DEBUGL (5)) if (DEBUGL (5))
{ {
globalError++; globalError++;
eprintf ("r%ii%i --> r%ii%i\n", r1, e1, r2, e2); eprintf ("r%ii%i --> r%ii%i\n", r1, e1, r2, e2);
globalError--; globalError--;
} }
#endif #endif
}
} }
return true; return true;
} }