Author: bart Date: 2008-03-06 18:02:37 +0000 (Thu, 06 Mar 2008) New Revision: 7578
Log: Cleaned up vc_min() and vc_combine() implementations. Modified: trunk/exp-drd/drd_vc.c Modified: trunk/exp-drd/drd_vc.c =================================================================== --- trunk/exp-drd/drd_vc.c 2008-03-06 14:07:32 UTC (rev 7577) +++ trunk/exp-drd/drd_vc.c 2008-03-06 18:02:37 UTC (rev 7578) @@ -135,44 +135,20 @@ } /** Compute elementwise minimum. */ -void vc_min(VectorClock* const result, - const VectorClock* const rhs) +void vc_min(VectorClock* const result, const VectorClock* const rhs) { unsigned i; unsigned j; - unsigned shared; - unsigned new_size; tl_assert(result); tl_assert(rhs); - /* First count the number of shared thread ID's. */ - j = 0; - shared = 0; - for (i = 0; i < result->size; i++) - { - while (j < rhs->size && rhs->vc[j].threadid < result->vc[i].threadid) - j++; - if (j >= rhs->size) - break; - if (result->vc[i].threadid == rhs->vc[j].threadid) - shared++; - } - vc_check(result); - new_size = result->size + rhs->size - shared; - if (new_size > result->capacity) - vc_reserve(result, new_size); - - vc_check(result); - /* Next, combine both vector clocks into one. */ i = 0; for (j = 0; j < rhs->size; j++) { - vc_check(result); - while (i < result->size && result->vc[i].threadid < rhs->vc[j].threadid) { /* Thread ID is missing in second vector clock. Clear the count. */ @@ -181,16 +157,10 @@ } if (i >= result->size) { - result->size++; - result->vc[i] = rhs->vc[j]; - vc_check(result); + break; } - else if (result->vc[i].threadid > rhs->vc[j].threadid) + if (result->vc[i].threadid <= rhs->vc[j].threadid) { - /* Thread ID is missing in first vector clock. Leave out. */ - } - else - { /* The thread ID is present in both vector clocks. Compute the minimum */ /* of vc[i].count and vc[j].count. */ tl_assert(result->vc[i].threadid == rhs->vc[j].threadid); @@ -198,7 +168,6 @@ { result->vc[i].count = rhs->vc[j].count; } - vc_check(result); } } vc_check(result); @@ -243,15 +212,12 @@ i = 0; for (j = 0; j < rhs->size; j++) { - vc_check(result); - while (i < result->size && result->vc[i].threadid < rhs->vc[j].threadid) i++; if (i >= result->size) { result->size++; result->vc[i] = rhs->vc[j]; - vc_check(result); } else if (result->vc[i].threadid > rhs->vc[j].threadid) { @@ -262,7 +228,6 @@ } result->size++; result->vc[i] = rhs->vc[j]; - vc_check(result); } else { @@ -271,7 +236,6 @@ { result->vc[i].count = rhs->vc[j].count; } - vc_check(result); } } vc_check(result); ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Valgrind-developers mailing list Valgrind-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-developers