[ltt-dev] [PATCH 2/2] Clean up style and redundancy

Benjamin Poirier benjamin.poirier at polymtl.ca
Sun Sep 19 21:01:44 EDT 2010


As the previous patch oultined, there was some repetition in getFactors() we
can do away with. While we're in the neighborhood, also wrap a > 80 col line.

Signed-off-by: Benjamin Poirier <benjamin.poirier at polymtl.ca>
---
 lttv/lttv/sync/factor_reduction_accuracy.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lttv/lttv/sync/factor_reduction_accuracy.c b/lttv/lttv/sync/factor_reduction_accuracy.c
index 885c52c..ccb0d03 100644
--- a/lttv/lttv/sync/factor_reduction_accuracy.c
+++ b/lttv/lttv/sync/factor_reduction_accuracy.c
@@ -244,8 +244,8 @@ static GArray* finalizeReductionAccuracy(SyncState* const syncState,
 	g_array_set_size(factors, syncState->traceNb);
 	for (i= 0; i < syncState->traceNb; i++)
 	{
-		getFactors(allFactors, predecessors, references, i, &g_array_index(factors,
-				Factors, i));
+		getFactors(allFactors, predecessors, references, i,
+			&g_array_index(factors, Factors, i));
 	}
 
 	if (syncState->stats)
@@ -426,6 +426,8 @@ static void getFactors(AllFactors* const allFactors, unsigned int** const
 	{
 		Factors previousVertexFactors;
 		unsigned int previousVertex= predecessors[reference][traceNum];
+		PairFactors* factorsPT= &pairFactors[previousVertex][traceNum],
+			*factorsTP= &pairFactors[traceNum][previousVertex];
 
 		getFactors(allFactors, predecessors, references, previousVertex,
 			&previousVertexFactors);
@@ -434,22 +436,20 @@ static void getFactors(AllFactors* const allFactors, unsigned int** const
 		 * pairFactors[row][col] converts the time from col to row, invert the
 		 * factors as necessary */
 
-		if (pairFactors[previousVertex][traceNum].approx != NULL)
+		if (factorsPT->approx != NULL)
 		{
 			factors->offset= previousVertexFactors.drift *
-				pairFactors[previousVertex][traceNum].approx->offset +
-				previousVertexFactors.offset;
+				factorsPT->approx->offset + previousVertexFactors.offset;
 			factors->drift= previousVertexFactors.drift *
-				pairFactors[previousVertex][traceNum].approx->drift;
+				factorsPT->approx->drift;
 		}
-		else if (pairFactors[traceNum][previousVertex].approx != NULL)
+		else if (factorsTP->approx != NULL)
 		{
 			factors->offset= previousVertexFactors.drift * (-1. *
-				pairFactors[traceNum][previousVertex].approx->offset /
-				pairFactors[traceNum][previousVertex].approx->drift) +
+				factorsTP->approx->offset / factorsTP->approx->drift) +
 				previousVertexFactors.offset;
 			factors->drift= previousVertexFactors.drift * (1. /
-				pairFactors[traceNum][previousVertex].approx->drift);
+				factorsTP->approx->drift);
 		}
 		else
 		{
-- 
1.7.1





More information about the lttng-dev mailing list