Skip to content

Commit ca32c01

Browse files
committed
refactor: assign error in if-else block
1 parent 2e5a47c commit ca32c01

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

pandas/_libs/src/parser/tokenizer.c

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,10 +1906,11 @@ int64_t str_to_int64(const char *p_item, int64_t int_min, int64_t int_max,
19061906
number = number * 10 - (d - '0');
19071907
d = *++p;
19081908
} else {
1909-
*error = ERROR_OVERFLOW;
1910-
int status = check_for_invalid_char(p);
1911-
if (status != 0) {
1909+
TokenizerError status;
1910+
if ((status = check_for_invalid_char(p)) > ERROR_OVERFLOW) {
19121911
*error = status;
1912+
} else {
1913+
*error = ERROR_OVERFLOW;
19131914
}
19141915
return 0;
19151916
}
@@ -1921,10 +1922,11 @@ int64_t str_to_int64(const char *p_item, int64_t int_min, int64_t int_max,
19211922
number = number * 10 - (d - '0');
19221923
d = *++p;
19231924
} else {
1924-
*error = ERROR_OVERFLOW;
1925-
int status = check_for_invalid_char(p);
1926-
if (status != 0) {
1925+
TokenizerError status;
1926+
if ((status = check_for_invalid_char(p)) > ERROR_OVERFLOW) {
19271927
*error = status;
1928+
} else {
1929+
*error = ERROR_OVERFLOW;
19281930
}
19291931
return 0;
19301932
}
@@ -1952,10 +1954,11 @@ int64_t str_to_int64(const char *p_item, int64_t int_min, int64_t int_max,
19521954
d = *++p;
19531955

19541956
} else {
1955-
*error = ERROR_OVERFLOW;
1956-
int status = check_for_invalid_char(p);
1957-
if (status != 0) {
1957+
TokenizerError status;
1958+
if ((status = check_for_invalid_char(p)) > ERROR_OVERFLOW) {
19581959
*error = status;
1960+
} else {
1961+
*error = ERROR_OVERFLOW;
19591962
}
19601963
return 0;
19611964
}
@@ -1968,10 +1971,11 @@ int64_t str_to_int64(const char *p_item, int64_t int_min, int64_t int_max,
19681971
d = *++p;
19691972

19701973
} else {
1971-
*error = ERROR_OVERFLOW;
1972-
int status = check_for_invalid_char(p);
1973-
if (status != 0) {
1974+
TokenizerError status;
1975+
if ((status = check_for_invalid_char(p)) > ERROR_OVERFLOW) {
19741976
*error = status;
1977+
} else {
1978+
*error = ERROR_OVERFLOW;
19751979
}
19761980
return 0;
19771981
}
@@ -2040,10 +2044,11 @@ uint64_t str_to_uint64(uint_state *state, const char *p_item, int64_t int_max,
20402044
d = *++p;
20412045

20422046
} else {
2043-
*error = ERROR_OVERFLOW;
2044-
int status = check_for_invalid_char(p);
2045-
if (status != 0) {
2047+
TokenizerError status;
2048+
if ((status = check_for_invalid_char(p)) > ERROR_OVERFLOW) {
20462049
*error = status;
2050+
} else {
2051+
*error = ERROR_OVERFLOW;
20472052
}
20482053
return 0;
20492054
}
@@ -2056,10 +2061,11 @@ uint64_t str_to_uint64(uint_state *state, const char *p_item, int64_t int_max,
20562061
d = *++p;
20572062

20582063
} else {
2059-
*error = ERROR_OVERFLOW;
2060-
int status = check_for_invalid_char(p);
2061-
if (status != 0) {
2064+
TokenizerError status;
2065+
if ((status = check_for_invalid_char(p)) > ERROR_OVERFLOW) {
20622066
*error = status;
2067+
} else {
2068+
*error = ERROR_OVERFLOW;
20632069
}
20642070
return 0;
20652071
}

0 commit comments

Comments
 (0)