xdiff/xdl_cleanup_records: make setting action easier to follow

Rewrite nested ternaries with a clear if/else ladder for
action1/action2 to improve readability while preserving
behavior.

Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ezekiel Newren
2026-04-29 22:08:14 +00:00
committed by Junio C Hamano
parent f99a023df2
commit c355f69cda
+12 -2
View File
@@ -302,7 +302,12 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
size_t mph1 = xdf1->recs[i].minimal_perfect_hash;
rcrec = cf->rcrecs[mph1];
nm = rcrec ? rcrec->len2 : 0;
action1[i] = (nm == 0) ? DISCARD: nm >= mlim1 ? INVESTIGATE: KEEP;
if (nm == 0)
action1[i] = DISCARD;
else if (nm < mlim1)
action1[i] = KEEP;
else /* nm >= mlim1 */
action1[i] = INVESTIGATE;
}
if (need_min) {
@@ -317,7 +322,12 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
size_t mph2 = xdf2->recs[i].minimal_perfect_hash;
rcrec = cf->rcrecs[mph2];
nm = rcrec ? rcrec->len1 : 0;
action2[i] = (nm == 0) ? DISCARD: nm >= mlim2 ? INVESTIGATE: KEEP;
if (nm == 0)
action2[i] = DISCARD;
else if (nm < mlim2)
action2[i] = KEEP;
else /* nm >= mlim2 */
action2[i] = INVESTIGATE;
}
/*