From: Matthew Fernandez Date: Thu, 6 Jan 2022 06:00:51 +0000 (-0800) Subject: lib/mingle: scope use of an array to a local temp X-Git-Tag: 3.0.0~88^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64fd4cd82f09b2735e98354051f49d217acda934;p=graphviz lib/mingle: scope use of an array to a local temp It is not clear to me why this loop was using the `sources` array. AFAICT the values written to this array are (1) not used by subsequent loop iterations (no loop-carried dependency) and (2) not used after the loop before being overwritten by other values. This change cuts the dependency. A future commit will refactor the allocation in this area to avoid allocating a possibly-unused array upfront. --- diff --git a/lib/mingle/ink.cpp b/lib/mingle/ink.cpp index 8079f0980..4ddcc3564 100644 --- a/lib/mingle/ink.cpp +++ b/lib/mingle/ink.cpp @@ -251,12 +251,11 @@ double ink(pedge* edges, int numEdges, int *pick, double *ink0, point_t *meet1, e = edges[i]; } x = e->x; - sources[i].x = x[0]; - sources[i].y = x[1]; + point_t source = {x[0], x[1]}; targets[i].x = x[e->dim*e->npoints - e->dim]; targets[i].y = x[e->dim*e->npoints - e->dim + 1]; - (*ink0) += hypot(sources[i].x - targets[i].x, sources[i].y - targets[i].y); - begin = addPoint (begin, scalePoint(sources[i], e->wgt)); + (*ink0) += hypot(source.x - targets[i].x, source.y - targets[i].y); + begin = addPoint (begin, scalePoint(source, e->wgt)); end = addPoint (end, scalePoint(targets[i], e->wgt)); wgt += e->wgt; }