From: Sebastian Harl Date: Wed, 2 Jul 2008 14:29:07 +0000 (+0200) Subject: src/utils_complain: Changed c_release() into a macro. X-Git-Tag: collectd-4.5.0~102 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6ddbe0026dea748db40ccc494b4f5048817b346a;p=collectd.git src/utils_complain: Changed c_release() into a macro. While the c_complain*() functions are usually used in error conditions only, c_release() is usually used whenever things went right (which should be the more common case ;-)). In order to minimize the overhead in the latter case, c_release() has been changed into a macro which checks if the complaint actually has to be released and calls c_do_release() in that case. This function then takes care of reporting the release-message (this is the original implementation of c_release()). So, we remove the overhead of a function call in the usual case, i.e. when we don't have to report any messages. Signed-off-by: Sebastian Harl Signed-off-by: Florian Forster --- diff --git a/src/utils_complain.c b/src/utils_complain.c index 9d0f4669..118245cc 100644 --- a/src/utils_complain.c +++ b/src/utils_complain.c @@ -79,7 +79,7 @@ void c_complain_once (int level, c_complain_t *c, const char *format, ...) va_end (ap); } /* c_complain_once */ -void c_release (int level, c_complain_t *c, const char *format, ...) +void c_do_release (int level, c_complain_t *c, const char *format, ...) { char message[512]; va_list ap; diff --git a/src/utils_complain.h b/src/utils_complain.h index 56e74eab..e93d823e 100644 --- a/src/utils_complain.h +++ b/src/utils_complain.h @@ -83,7 +83,12 @@ void c_complain_once (int level, c_complain_t *c, const char *format, ...); * * See `c_complain' for a description of the parameters. */ -void c_release (int level, c_complain_t *c, const char *format, ...); +void c_do_release (int level, c_complain_t *c, const char *format, ...); +#define c_release(level, c, ...) \ + do { \ + if ((c)->interval != 0) \ + c_do_release(level, c, __VA_ARGS__); \ + } while (0) #endif /* UTILS_COMPLAIN_H */