Skip to content

Commit fa1edff

Browse files
committed
py: Remove unnecessary and unused sgn argument from pfenv_print_mp_int.
1 parent 6837d46 commit fa1edff

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

py/objstr.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwa
10831083
if (arg_looks_integer(arg)) {
10841084
switch (type) {
10851085
case 'b':
1086-
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 2, 'a', flags, fill, width, 0);
1086+
pfenv_print_mp_int(&pfenv_vstr, arg, 2, 'a', flags, fill, width, 0);
10871087
continue;
10881088

10891089
case 'c':
@@ -1096,20 +1096,20 @@ mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwa
10961096
case '\0': // No explicit format type implies 'd'
10971097
case 'n': // I don't think we support locales in uPy so use 'd'
10981098
case 'd':
1099-
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 10, 'a', flags, fill, width, 0);
1099+
pfenv_print_mp_int(&pfenv_vstr, arg, 10, 'a', flags, fill, width, 0);
11001100
continue;
11011101

11021102
case 'o':
11031103
if (flags & PF_FLAG_SHOW_PREFIX) {
11041104
flags |= PF_FLAG_SHOW_OCTAL_LETTER;
11051105
}
11061106

1107-
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 8, 'a', flags, fill, width, 0);
1107+
pfenv_print_mp_int(&pfenv_vstr, arg, 8, 'a', flags, fill, width, 0);
11081108
continue;
11091109

11101110
case 'X':
11111111
case 'x':
1112-
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 16, type - ('X' - 'A'), flags, fill, width, 0);
1112+
pfenv_print_mp_int(&pfenv_vstr, arg, 16, type - ('X' - 'A'), flags, fill, width, 0);
11131113
continue;
11141114

11151115
case 'e':
@@ -1377,7 +1377,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
13771377
case 'd':
13781378
case 'i':
13791379
case 'u':
1380-
pfenv_print_mp_int(&pfenv_vstr, arg_as_int(arg), 1, 10, 'a', flags, fill, width, prec);
1380+
pfenv_print_mp_int(&pfenv_vstr, arg_as_int(arg), 10, 'a', flags, fill, width, prec);
13811381
break;
13821382

13831383
#if MICROPY_PY_BUILTINS_FLOAT
@@ -1395,7 +1395,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
13951395
if (alt) {
13961396
flags |= (PF_FLAG_SHOW_PREFIX | PF_FLAG_SHOW_OCTAL_LETTER);
13971397
}
1398-
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 8, 'a', flags, fill, width, prec);
1398+
pfenv_print_mp_int(&pfenv_vstr, arg, 8, 'a', flags, fill, width, prec);
13991399
break;
14001400

14011401
case 'r':
@@ -1419,7 +1419,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
14191419

14201420
case 'X':
14211421
case 'x':
1422-
pfenv_print_mp_int(&pfenv_vstr, arg, 1, 16, *str - ('X' - 'A'), flags | alt, fill, width, prec);
1422+
pfenv_print_mp_int(&pfenv_vstr, arg, 16, *str - ('X' - 'A'), flags | alt, fill, width, prec);
14231423
break;
14241424

14251425
default:

py/pfenv.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,7 @@ int pfenv_print_int(const pfenv_t *pfenv, mp_uint_t x, int sgn, int base, int ba
178178
return len;
179179
}
180180

181-
int pfenv_print_mp_int(const pfenv_t *pfenv, mp_obj_t x, int sgn, int base, int base_char, int flags, char fill, int width, int prec) {
182-
(void)sgn; // TODO why is sgn unused?
183-
181+
int pfenv_print_mp_int(const pfenv_t *pfenv, mp_obj_t x, int base, int base_char, int flags, char fill, int width, int prec) {
184182
if (!MP_OBJ_IS_INT(x)) {
185183
// This will convert booleans to int, or raise an error for
186184
// non-integer types.

py/pfenv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void pfenv_vstr_add_strn(void *data, const char *str, mp_uint_t len);
5151

5252
int pfenv_print_strn(const pfenv_t *pfenv, const char *str, mp_uint_t len, int flags, char fill, int width);
5353
int pfenv_print_int(const pfenv_t *pfenv, mp_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width);
54-
int pfenv_print_mp_int(const pfenv_t *pfenv, mp_obj_t x, int sgn, int base, int base_char, int flags, char fill, int width, int prec);
54+
int pfenv_print_mp_int(const pfenv_t *pfenv, mp_obj_t x, int base, int base_char, int flags, char fill, int width, int prec);
5555
#if MICROPY_PY_BUILTINS_FLOAT
5656
int pfenv_print_float(const pfenv_t *pfenv, mp_float_t f, char fmt, int flags, char fill, int width, int prec);
5757
#endif

0 commit comments

Comments
 (0)