@@ -508,31 +508,28 @@ OUT* connected_components3d_6_binary(
508508 for (int64_t x = xstart; x < xend; x++) {
509509 loc = x + sx * (y + sy * z);
510510
511- const T cur = in_labels[loc];
512-
513- if (cur == 0 ) {
511+ if (in_labels[loc] == 0 ) {
514512 continue ;
515513 }
516-
517- if (x > 0 && in_labels[loc + M]) {
514+ else if (x > 0 && in_labels[loc + M]) {
518515 out_labels[loc] = out_labels[loc + M];
519516
520- if (y > 0 && in_labels[loc + K] && cur != in_labels[loc + J]) {
517+ if (y > 0 && in_labels[loc + K] && ! in_labels[loc + J]) {
521518 equivalences.unify (out_labels[loc], out_labels[loc + K]);
522519 if (z > 0 && in_labels[loc + E]) {
523- if (cur != in_labels[loc + D] && cur != in_labels[loc + B]) {
520+ if (! in_labels[loc + D] && ! in_labels[loc + B]) {
524521 equivalences.unify (out_labels[loc], out_labels[loc + E]);
525522 }
526523 }
527524 }
528- else if (z > 0 && in_labels[loc + E] && cur != in_labels[loc + D]) {
525+ else if (z > 0 && in_labels[loc + E] && ! in_labels[loc + D]) {
529526 equivalences.unify (out_labels[loc], out_labels[loc + E]);
530527 }
531528 }
532529 else if (y > 0 && in_labels[loc + K]) {
533530 out_labels[loc] = out_labels[loc + K];
534531
535- if (z > 0 && in_labels[loc + E] && cur != in_labels[loc + B]) {
532+ if (z > 0 && in_labels[loc + E] && ! in_labels[loc + B]) {
536533 equivalences.unify (out_labels[loc], out_labels[loc + E]);
537534 }
538535 }
@@ -631,22 +628,19 @@ OUT* connected_components2d_4_binary(
631628 // Raster Scan 1: Set temporary labels and
632629 // record equivalences in a disjoint set.
633630
634- T cur = 0 ;
635631 for (int64_t y = 0 ; y < sy; y++, row++) {
636632 const int64_t xstart = runs[row << 1 ];
637633 const int64_t xend = runs[(row << 1 ) + 1 ];
638634
639635 for (int64_t x = xstart; x < xend; x++) {
640636 loc = x + sx * y;
641- cur = in_labels[loc];
642637
643- if (cur == 0 ) {
638+ if (in_labels[loc] == 0 ) {
644639 continue ;
645640 }
646-
647- if (x > 0 && in_labels[loc + B]) {
641+ else if (x > 0 && in_labels[loc + B]) {
648642 out_labels[loc + A] = out_labels[loc + B];
649- if (y > 0 && cur != in_labels[loc + D] && in_labels[loc + C]) {
643+ if (y > 0 && ! in_labels[loc + D] && in_labels[loc + C]) {
650644 equivalences.unify (out_labels[loc + A], out_labels[loc + C]);
651645 }
652646 }
0 commit comments