From 61557ea331cfddb7ea42e6de75e46abd0b42e963 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 11 Dec 2022 16:46:38 -0500 Subject: [PATCH] perf: avoid gumbo_debug function calls when GUMBO_DEBUG isn't def'd Part of #2722 Co-authored-by: Stephen Checkoway --- gumbo-parser/src/util.c | 2 -- gumbo-parser/src/util.h | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gumbo-parser/src/util.c b/gumbo-parser/src/util.c index d1ab2d7acb..6238c29605 100644 --- a/gumbo-parser/src/util.c +++ b/gumbo-parser/src/util.c @@ -63,6 +63,4 @@ void gumbo_debug(const char* format, ...) { va_end(args); fflush(stdout); } -#else -void gumbo_debug(const char* UNUSED_ARG(format), ...) {} #endif diff --git a/gumbo-parser/src/util.h b/gumbo-parser/src/util.h index dfdf465bc0..64170e5cd0 100644 --- a/gumbo-parser/src/util.h +++ b/gumbo-parser/src/util.h @@ -21,7 +21,11 @@ void* gumbo_realloc(void* ptr, size_t size) RETURNS_NONNULL; void gumbo_free(void* ptr); // Debug wrapper for printf +#ifdef GUMBO_DEBUG void gumbo_debug(const char* format, ...) PRINTF(1); +#else +static inline void PRINTF(1) gumbo_debug(const char* UNUSED_ARG(format), ...) {}; +#endif #ifdef __cplusplus }