summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-07-30 13:45:44 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-07-30 16:47:02 +0300
commitb76bd91beef9a279cc730ce7167408b2c01953b7 (patch)
tree5a042eced182286828871467cd2404da52a61d86 /src
parentf54936e762d660a155d05c7b52c2b424936ebf32 (diff)
wrapper: improve performance of verbose_log
This reduces the number of syscalls per call from 3 to 1, on one specific game when piping everything to /dev/null this reduces the runtime from 14.115s to 8.800s. Signed-off-by: Jari Vetoniemi <mailroxas@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/wrapper/wrapper.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wrapper/wrapper.c b/src/wrapper/wrapper.c
index d78f1a4..b3249b6 100644
--- a/src/wrapper/wrapper.c
+++ b/src/wrapper/wrapper.c
@@ -21,12 +21,12 @@ verbose_log(const char *fmt, ...)
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&mutex);
- fprintf(stderr, "%lu: ", pthread_self());
va_list ap;
va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
+ char buf[1024];
+ vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
- fputc('\n', stderr);
+ fprintf(stderr, "%lu: %s\n", pthread_self(), buf);
pthread_mutex_unlock(&mutex);
}