Skip to content

Commit 2287944

Browse files
committed
refactor: don't pass PROCESSED_WORD_CAPACITY as a separate argument
1 parent 87789e6 commit 2287944

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pandas/_libs/src/parser/tokenizer.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,15 +1879,16 @@ static inline bool has_only_spaces(const char *str) {
18791879
/* Copy a string without `char_to_remove` into `output`,
18801880
* while ensuring it's null terminated.
18811881
*/
1882-
static void copy_string_without_char(char *output, const char *str,
1883-
char char_to_remove, size_t output_size) {
1882+
static void copy_string_without_char(char output[PROCESSED_WORD_CAPACITY],
1883+
const char *str, char char_to_remove) {
18841884
size_t i = 0;
1885-
for (const char *src = str; *src != '\0' && i < output_size; src++) {
1885+
for (const char *src = str; *src != '\0' && i < PROCESSED_WORD_CAPACITY;
1886+
src++) {
18861887
if (*src != char_to_remove) {
18871888
output[i++] = *src;
18881889
}
18891890
}
1890-
if (i < output_size) {
1891+
if (i < PROCESSED_WORD_CAPACITY) {
18911892
output[i] = '\0';
18921893
} else {
18931894
// str is too big, probably would overflow
@@ -1914,7 +1915,7 @@ int64_t str_to_int64(const char *p_item, int64_t int_min, int64_t int_max,
19141915
errno = 0;
19151916
if (tsep != '\0' && strchr(p_item, tsep) != NULL) {
19161917
char buffer[PROCESSED_WORD_CAPACITY];
1917-
copy_string_without_char(buffer, p_item, tsep, PROCESSED_WORD_CAPACITY);
1918+
copy_string_without_char(buffer, p_item, tsep);
19181919
p_item = buffer;
19191920
}
19201921

@@ -1969,7 +1970,7 @@ uint64_t str_to_uint64(uint_state *state, const char *p_item, int64_t int_max,
19691970
errno = 0;
19701971
if (tsep != '\0' && strchr(p_item, tsep) != NULL) {
19711972
char buffer[PROCESSED_WORD_CAPACITY];
1972-
copy_string_without_char(buffer, p_item, tsep, PROCESSED_WORD_CAPACITY);
1973+
copy_string_without_char(buffer, p_item, tsep);
19731974
p_item = buffer;
19741975
}
19751976

0 commit comments

Comments
 (0)