From: Florian Weimer Date: Mon, 19 Dec 2022 17:56:54 +0000 (+0100) Subject: stdio-common: Add lock optimization to vfprintf and vfwprintf X-Git-Tag: glibc-2.37~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d0005b54af06d3bb7ab9f85bfe6a27552b11f74;p=thirdparty%2Fglibc.git stdio-common: Add lock optimization to vfprintf and vfwprintf After the rewrite and the implicit unbuffered streams handling, this is very straightforward to add. Reviewed-by: Adhemerval Zanella --- diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c index 83a6aea510e..23ada8d0ff5 100644 --- a/stdio-common/vfprintf-internal.c +++ b/stdio-common/vfprintf-internal.c @@ -1452,6 +1452,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags) return EOF; #endif + if (!_IO_need_lock (s)) + { + struct Xprintf (buffer_to_file) wrap; + Xprintf (buffer_to_file_init) (&wrap, s); + Xprintf_buffer (&wrap.base, format, ap, mode_flags); + return Xprintf (buffer_to_file_done) (&wrap); + } + int done; /* Lock stream. */