From 4f811ff6e0b765f667e6bbaa0e0e869ceef535d4 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 16 Dec 2017 15:46:37 +0100 Subject: [PATCH] [logger] Return early if severity or domain do not match --- src/logger.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/logger.c b/src/logger.c index db8dd96d..65330db2 100644 --- a/src/logger.c +++ b/src/logger.c @@ -164,6 +164,11 @@ DPRINTF(int severity, int domain, const char *fmt, ...) { va_list ap; + // If domain and severity do not match the current log configuration, return early to + // safe some unnecessary code execution (tiny performance gain) + if (logger_initialized && (!((1 << domain) & logdomains) || (severity > threshold))) + return; + va_start(ap, fmt); vlogger(severity, domain, fmt, ap); va_end(ap);