Skip to content

Commit 8fede1f

Browse files
author
Marco Gorelli
committed
simplify
1 parent a6ea6d0 commit 8fede1f

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

pandas/_libs/tslibs/src/datetime/np_datetime_strings.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,16 @@ This file implements string parsing and creation for NumPy datetime.
6868
*/
6969

7070
#define FORMAT_STARTSWITH(ch) \
71-
if (exact) { \
72-
if (!format_len || *format != ch) { \
71+
/* Always error on character mismatch conditioned on non-exhausted format, \
72+
or when format is exhausted in the exact case. */ \
73+
if ((format_len && *format != ch) || (exact && !format_len)){ \
7374
goto parse_error; \
7475
} \
75-
++format; \
76-
--format_len; \
77-
} else { \
78-
if (format_len > 0) { \
79-
if (*format != ch) { \
80-
goto parse_error; \
81-
} \
82-
++format; \
83-
--format_len; \
76+
/* Advance if format is not exhausted */ \
77+
if (format_len) { \
78+
++format; \
79+
--format_len; \
8480
} \
85-
} \
8681

8782
int parse_iso_8601_datetime(const char *str, int len, int want_exc,
8883
npy_datetimestruct *out,

0 commit comments

Comments
 (0)