Skip to content

Commit 88c68fa

Browse files
committed
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>
1 parent fec2b0f commit 88c68fa

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

xdiff/xprepare.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,24 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
303303
size_t mph1 = xdf1->recs[i].minimal_perfect_hash;
304304
rcrec = cf->rcrecs[mph1];
305305
nm = rcrec ? rcrec->len2 : 0;
306-
action1[i] = (nm == 0) ? DISCARD: nm >= mlim1 ? INVESTIGATE: KEEP;
306+
if (nm == 0)
307+
action1[i] = DISCARD;
308+
else if (nm < mlim1)
309+
action1[i] = KEEP;
310+
else /* nm >= mlim1 */
311+
action1[i] = INVESTIGATE;
307312
}
308313

309314
for (i = xdf2->dstart; i <= xdf2->dend; i++) {
310315
size_t mph2 = xdf2->recs[i].minimal_perfect_hash;
311316
rcrec = cf->rcrecs[mph2];
312317
nm = rcrec ? rcrec->len1 : 0;
313-
action2[i] = (nm == 0) ? DISCARD: nm >= mlim2 ? INVESTIGATE: KEEP;
318+
if (nm == 0)
319+
action2[i] = DISCARD;
320+
else if (nm < mlim2)
321+
action2[i] = KEEP;
322+
else /* nm >= mlim2 */
323+
action2[i] = INVESTIGATE;
314324
}
315325

316326
/*

0 commit comments

Comments
 (0)