]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
stdio-common: Add lock optimization to vfprintf and vfwprintf
authorFlorian Weimer <fweimer@redhat.com>
Thu, 18 Aug 2022 06:49:54 +0000 (08:49 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 12 Dec 2022 14:39:05 +0000 (15:39 +0100)
After the rewrite and the implicit unbuffered streams handling, this
is very straightforward to add.

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.  */