py/objstr: .format(): Avoid call to vstr_null_terminated_str().
By comparing with string end pointer instead of checking for NUL byte. Should alleviate reallocations and fragmentation a tiny bit.
This commit is contained in:
parent
460b086333
commit
6de8dbb488
|
@ -1043,7 +1043,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
|
||||||
// recursively call the formatter to format any nested specifiers
|
// recursively call the formatter to format any nested specifiers
|
||||||
MP_STACK_CHECK();
|
MP_STACK_CHECK();
|
||||||
vstr_t format_spec_vstr = mp_obj_str_format_helper(format_spec, str, arg_i, n_args, args, kwargs);
|
vstr_t format_spec_vstr = mp_obj_str_format_helper(format_spec, str, arg_i, n_args, args, kwargs);
|
||||||
const char *s = vstr_null_terminated_str(&format_spec_vstr);
|
const char *s = format_spec_vstr.buf;
|
||||||
const char *stop = s + format_spec_vstr.len;
|
const char *stop = s + format_spec_vstr.len;
|
||||||
if (isalignment(*s)) {
|
if (isalignment(*s)) {
|
||||||
align = *s++;
|
align = *s++;
|
||||||
|
@ -1083,7 +1083,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
|
||||||
if (istype(*s)) {
|
if (istype(*s)) {
|
||||||
type = *s++;
|
type = *s++;
|
||||||
}
|
}
|
||||||
if (*s) {
|
if (s != stop) {
|
||||||
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
|
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
|
||||||
terse_str_format_value_error();
|
terse_str_format_value_error();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue