Skip to content

Commit 9649590

Browse files
committed
Replace strncmp with direct char comparison
1 parent 7f201d9 commit 9649590

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Modules/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,11 @@ PyObject* _utf_8_bytes_dedent(PyObject *bytes){
262262
while (line) {
263263
// Move the pointer up to the first non-space character
264264
char *first_nonspace = line;
265-
while (strncmp(first_nonspace, " ", 1) == 0){
265+
while (*first_nonspace == ' '){
266266
first_nonspace++;
267267
}
268268
// Only check lines that contain non-whitespace characters
269-
if (strncmp(first_nonspace, "\0", 1)) {
269+
if (*first_nonspace != '\0') {
270270

271271
Py_ssize_t num_leading_spaces = first_nonspace - line;
272272
if (num_leading_spaces < num_common_leading_spaces) {
@@ -359,7 +359,7 @@ pymain_run_command(wchar_t *command)
359359
}
360360

361361
// Only perform auto-dedent if the string starts with a newline
362-
if (strncmp(PyBytes_AsString(bytes), "\n", 1) == 0) {
362+
if (*PyBytes_AsString(bytes) == '\n') {
363363
PyObject *new_bytes = _utf_8_bytes_dedent(bytes);
364364
if (new_bytes == NULL) {
365365
goto error;

0 commit comments

Comments
 (0)