Skip to content

Commit 0b19208

Browse files
committed
fix: use memchr to find if need to process the word
1 parent c4e0e25 commit 0b19208

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/_libs/src/parser/tokenizer.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,8 +1937,9 @@ int64_t str_to_int64(const char *p_item, int64_t int_min, int64_t int_max,
19371937

19381938
errno = 0;
19391939
char buffer[PROCESSED_WORD_CAPACITY];
1940-
if (tsep != '\0' && strchr(p_item, tsep) != NULL) {
1941-
int status = copy_string_without_char(buffer, p_item, strlen(p_item), tsep);
1940+
size_t str_len = strlen(p_item);
1941+
if (tsep != '\0' && memchr(p_item, tsep, str_len) != NULL) {
1942+
int status = copy_string_without_char(buffer, p_item, str_len, tsep);
19421943

19431944
if (status != 0) {
19441945
// Word is too big, probably will cause an overflow
@@ -1999,7 +2000,8 @@ uint64_t str_to_uint64(uint_state *state, const char *p_item, int64_t int_max,
19992000

20002001
errno = 0;
20012002
char buffer[PROCESSED_WORD_CAPACITY];
2002-
if (tsep != '\0' && strchr(p_item, tsep) != NULL) {
2003+
size_t str_len = strlen(p_item);
2004+
if (tsep != '\0' && memchr(p_item, tsep, str_len) != NULL) {
20032005
int status = copy_string_without_char(buffer, p_item, strlen(p_item), tsep);
20042006

20052007
if (status != 0) {

0 commit comments

Comments
 (0)