libc/stdio: Don't count the output length repeatly in vsprintf_internal
let's reuse the counting from lib_outstream_s::nput instead Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
33e35c6ce3
commit
7568a0df22
@ -73,7 +73,7 @@
|
||||
# undef putc
|
||||
#endif
|
||||
|
||||
#define putc(c,stream) (total_len++, (stream)->put(stream, c))
|
||||
#define putc(c,stream) (stream)->put(stream, c)
|
||||
|
||||
/* Order is relevant here and matches order in format string */
|
||||
|
||||
@ -201,9 +201,9 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
|
||||
FAR const char *pnt;
|
||||
size_t size;
|
||||
unsigned char len;
|
||||
int total_len = 0;
|
||||
|
||||
#ifdef CONFIG_LIBC_NUMBERED_ARGS
|
||||
int total_len = 0;
|
||||
int argnumber = 0;
|
||||
#endif
|
||||
|
||||
@ -1357,7 +1357,11 @@ tail:
|
||||
}
|
||||
|
||||
ret:
|
||||
return total_len;
|
||||
#ifdef CONFIG_LIBC_NUMBERED_ARGS
|
||||
return stream ? stream->nput : total_len;
|
||||
#else
|
||||
return stream->nput;
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user