]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
stdio-common: Add lock optimization to vfprintf and vfwprintf
authorFlorian Weimer <fweimer@redhat.com>
Mon, 19 Dec 2022 17:56:54 +0000 (18:56 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 19 Dec 2022 17:56:54 +0000 (18:56 +0100)
After the rewrite and the implicit unbuffered streams handling, this
is very straightforward to add.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
stdio-common/vfprintf-internal.c

index 83a6aea510e1d1fa087748e83722d79092f8e313..23ada8d0ff5105858253201d30ad829fd0cbea04 100644 (file)
@@ -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.  */