Skip to content

Commit 07c147d

Browse files
committed
minor, leave faster branchless algorithm for abbreviated months in date-core-strpf routines
1 parent 383f1d9 commit 07c147d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/date-core-strpf.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,22 @@ __strpd_card(struct strpd_s *d, const char *sp, struct dt_spec_s s, char **ep)
316316
dut_long_mon, dut_nlong_mon);
317317
break;
318318
case DT_SPMOD_ABBR: {
319+
#if 0
320+
/* branchless version but no error handling */
321+
int r = *sp++ - 'E';
322+
r -= (r >> 2);
323+
r -= (r >= 12) << 1;
324+
r -= (r > 8);
325+
r -= (r >= 12);
326+
d->m = r;
327+
#else
319328
const char *pos;
320329
if ((pos = strchr(dut_abab_mon, *sp++)) != NULL) {
321330
d->m = pos - dut_abab_mon;
322331
} else {
323332
d->m = -1;
324333
}
334+
#endif
325335
break;
326336
}
327337
case DT_SPMOD_ILL:

0 commit comments

Comments
 (0)