Skip to content

Commit 9d2c72a

Browse files
committed
py/objstr: Remove unnecessary "sign" variable in formatting code.
1 parent 2138258 commit 9d2c72a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

py/objstr.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,6 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
10781078
arg = mp_obj_new_str_from_vstr(&mp_type_str, &arg_vstr);
10791079
}
10801080

1081-
char sign = '\0';
10821081
char fill = '\0';
10831082
char align = '\0';
10841083
int width = -1;
@@ -1114,7 +1113,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
11141113
} else if (*s == ' ') {
11151114
flags |= PF_FLAG_SPACE_SIGN;
11161115
}
1117-
sign = *s++;
1116+
s++;
11181117
}
11191118
if (*s == '#') {
11201119
flags |= PF_FLAG_SHOW_PREFIX;
@@ -1160,7 +1159,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
11601159
fill = ' ';
11611160
}
11621161

1163-
if (sign) {
1162+
if (flags & (PF_FLAG_SHOW_SIGN | PF_FLAG_SPACE_SIGN)) {
11641163
if (type == 's') {
11651164
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
11661165
terse_str_format_value_error();
@@ -1176,8 +1175,6 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
11761175
"sign not allowed with integer format specifier 'c'");
11771176
}
11781177
}
1179-
} else {
1180-
sign = '-';
11811178
}
11821179

11831180
switch (align) {

0 commit comments

Comments
 (0)