Skip to content

Commit 8a16534

Browse files
committed
work around gcc bug (closes #32)
1 parent e0586a6 commit 8a16534

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

utils/geom.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,35 +1524,35 @@ static void find_best_partition(int nobjects, const geom_box_object *objects,
15241524

15251525
for (i = 0; i < nobjects; ++i) {
15261526
cur_partition = VEC_I(objects[i].box.high, divide_axis) * (1 + SMALL);
1527-
cur_n1 = cur_n2 = 0;
1528-
for (j = 0; j < nobjects; ++j) {
1529-
if (VEC_I(objects[j].box.low, divide_axis) <= cur_partition)
1530-
++cur_n1;
1531-
if (VEC_I(objects[j].box.high, divide_axis) >= cur_partition)
1532-
++cur_n2;
1533-
}
1534-
CHECK(cur_n1 + cur_n2 >= nobjects, "bug 1 in find_best_partition");
1535-
if (MAX(cur_n1, cur_n2) < MAX(*n1, *n2)) {
1536-
*best_partition = cur_partition;
1537-
*n1 = cur_n1;
1538-
*n2 = cur_n2;
1539-
}
1527+
cur_n1 = cur_n2 = 0;
1528+
for (j = 0; j < nobjects; ++j) {
1529+
double low = VEC_I(objects[j].box.low, divide_axis);
1530+
double high = VEC_I(objects[j].box.high, divide_axis);
1531+
cur_n1 += low <= cur_partition;
1532+
cur_n2 += high >= cur_partition;
1533+
}
1534+
CHECK(cur_n1 + cur_n2 >= nobjects, "assertion failure 1 in find_best_partition");
1535+
if (MAX(cur_n1, cur_n2) < MAX(*n1, *n2)) {
1536+
*best_partition = cur_partition;
1537+
*n1 = cur_n1;
1538+
*n2 = cur_n2;
1539+
}
15401540
}
15411541
for (i = 0; i < nobjects; ++i) {
15421542
cur_partition = VEC_I(objects[i].box.low, divide_axis) * (1 - SMALL);
1543-
cur_n1 = cur_n2 = 0;
1544-
for (j = 0; j < nobjects; ++j) {
1545-
if (VEC_I(objects[j].box.low, divide_axis) <= cur_partition)
1546-
++cur_n1;
1547-
if (VEC_I(objects[j].box.high, divide_axis) >= cur_partition)
1548-
++cur_n2;
1549-
}
1550-
CHECK(cur_n1 + cur_n2 >= nobjects, "bug 2 in find_best_partition");
1551-
if (MAX(cur_n1, cur_n2) < MAX(*n1, *n2)) {
1552-
*best_partition = cur_partition;
1553-
*n1 = cur_n1;
1554-
*n2 = cur_n2;
1555-
}
1543+
cur_n1 = cur_n2 = 0;
1544+
for (j = 0; j < nobjects; ++j) {
1545+
double low = VEC_I(objects[j].box.low, divide_axis);
1546+
double high = VEC_I(objects[j].box.high, divide_axis);
1547+
cur_n1 += low <= cur_partition;
1548+
cur_n2 += high >= cur_partition;
1549+
}
1550+
CHECK(cur_n1 + cur_n2 >= nobjects, "assertion failure 2 in find_best_partition");
1551+
if (MAX(cur_n1, cur_n2) < MAX(*n1, *n2)) {
1552+
*best_partition = cur_partition;
1553+
*n1 = cur_n1;
1554+
*n2 = cur_n2;
1555+
}
15561556
}
15571557
}
15581558

0 commit comments

Comments
 (0)