Skip to content

Commit c82c71c

Browse files
committed
simplify 3d
1 parent 8281775 commit c82c71c

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

c/nondominated.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ find_nondominated_3d_impl_sorted(const double ** rows, size_t size,
363363

364364
// In this context, size means "no dominated solution found".
365365
size_t new_size = size, j = 1, k = 0;
366-
const double * last_dom = NULL;
366+
size_t last_dom_pos = size;
367367
const double * restrict pk = rows[0];
368368
do {
369369
bool dominated;
@@ -414,24 +414,24 @@ find_nondominated_3d_impl_sorted(const double ** rows, size_t size,
414414
// Handle duplicates and points that are dominated by the immediate
415415
// previous one.
416416
const bool k_eq_j = (pk[0] == pj[0]) & (pk[1] == pj[1]) & (pk[2] == pj[2]);
417-
if (!keep_weakly) { // We don't keep duplicates;
418-
if (unlikely(k_eq_j) && pj < pk) { // Only the first duplicated point is kept.
417+
if (!keep_weakly) { // Don't keep duplicates;
418+
if (pj < pk && unlikely(k_eq_j)) { // Only the first duplicated point is kept.
419419
if (find_one_dominated) {
420420
// In this context, it means "position of the first dominated solution found".
421421
new_size = k;
422422
goto early_end;
423423
}
424-
last_dom = pk;
424+
last_dom_pos = k;
425425
rows[k] = NULL;
426426
new_size--;
427427
dominated = false; // Do not delete pj.
428428
} else {
429429
dominated = true;
430430
}
431-
} else { // or it is not a duplicate, so it is non-weakly dominated;
432-
dominated = likely(!k_eq_j)
433-
// or pk was dominated, then this one is also dominated.
434-
|| last_dom == pk;
431+
} else { // or pk was dominated, then this one is also dominated;
432+
dominated = (last_dom_pos == k)
433+
// or it is not a duplicate, so it is non-weakly dominated.
434+
|| likely(!k_eq_j);
435435
}
436436
DEBUG2(printf_point("weakly dominated by pk: ", pk, 3, "\n"));
437437
}
@@ -441,7 +441,7 @@ find_nondominated_3d_impl_sorted(const double ** rows, size_t size,
441441
new_size = j;
442442
goto early_end;
443443
}
444-
last_dom = pj;
444+
last_dom_pos = j;
445445
rows[j] = NULL;
446446
new_size--;
447447
} else {

0 commit comments

Comments
 (0)