Gitlab updates will be applied at 1:30pm, (17:30 UTC), today. No downtime expected.

Commit 222fe37b authored by Ben Boeckel's avatar Ben Boeckel

vtkKdNode, vtkOctreePointLocatorNode: don't assign after a short-circuit

Conditionals may short-circuit and assignments anywhere other than the
first sub-expression is not guaranteed to be executed, so just always do
the subtraction.

Change-Id: I8e1ed5ad4f1ac3257209ee0386c5965cfd8d1e2f
parent 6b41931d
......@@ -363,43 +363,49 @@ double vtkKdNode::_GetDistance2ToBoundary(
int first = 1;
minDistance = VTK_FLOAT_MAX; // Suppresses warning message.
dist = x - xmin;
if ((xmin != outerBoundaryMin[0]) &&
(((dist = x - xmin) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 0;
minDistance = dist;
first = 0;
}
dist = xmax - x;
if ((xmax != outerBoundaryMax[0]) &&
(((dist = xmax - x) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 1;
minDistance = dist;
first = 0;
}
dist = y - ymin;
if ((ymin != outerBoundaryMin[1]) &&
(((dist = y - ymin) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 2;
minDistance = dist;
first = 0;
}
dist = ymax - y;
if ((ymax != outerBoundaryMax[1]) &&
(((dist = ymax - y) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 3;
minDistance = dist;
first = 0;
}
dist = z - zmin;
if ((zmin != outerBoundaryMin[2]) &&
(((dist = z - zmin) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 4;
minDistance = dist;
first = 0;
}
dist = zmax - z;
if ((zmax != outerBoundaryMax[2]) &&
(((dist = zmax - z) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 5;
minDistance = dist;
......
......@@ -366,43 +366,49 @@ double vtkOctreePointLocatorNode::_GetDistance2ToBoundary(
int first = 1;
minDistance = VTK_FLOAT_MAX; // Suppresses warning message.
dist = x - xmin;
if ((xmin != outerBoundaryMin[0]) &&
(((dist = x - xmin) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 0;
minDistance = dist;
first = 0;
}
dist = xmax - x;
if ((xmax != outerBoundaryMax[0]) &&
(((dist = xmax - x) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 1;
minDistance = dist;
first = 0;
}
dist = y - ymin;
if ((ymin != outerBoundaryMin[1]) &&
(((dist = y - ymin) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 2;
minDistance = dist;
first = 0;
}
dist = ymax - y;
if ((ymax != outerBoundaryMax[1]) &&
(((dist = ymax - y) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 3;
minDistance = dist;
first = 0;
}
dist = z - zmin;
if ((zmin != outerBoundaryMin[2]) &&
(((dist = z - zmin) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 4;
minDistance = dist;
first = 0;
}
dist = zmax - z;
if ((zmax != outerBoundaryMax[2]) &&
(((dist = zmax - z) < minDistance) || first))
((dist < minDistance) || first))
{
mindim = 5;
minDistance = dist;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment