-
Notifications
You must be signed in to change notification settings - Fork 455
Avoid conditional compilation on whether tracing is enabled #914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid conditional compilation on whether tracing is enabled #914
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume these changes suggest the runtime impact of disabled tracing utilities is not significant enough to justify their conditional compile-time compilation and corresponding maintenance burden. It seems like the compilers are also gracious enough not to warn about the always true/false conditions predecated on MONGOC_TRACE_ENABLED
. LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, LGTM!
@@ -85,10 +103,8 @@ mongoc_log (mongoc_log_level_t log_level, | |||
bson_once (&once, &_mongoc_ensure_mutex_once); | |||
|
|||
stop_logging = !gLogFunc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this check be combined into _mongoc_log_trace_is_enabled()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure. I left the logic as close to the original as possible.
*/ | ||
#define MONGOC_TRACE @MONGOC_TRACE@ | ||
#cmakedefine01 MONGOC_TRACE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unexpectedly broke PHPC's build system (autotools). I've reported CDRIVER-4247 to request a more portable approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in #917.
Macros that discard their arguments under certain configurations can lead to missed refactors and unknowingly breaking code. This changeset changes conditional tracing to use C-language-level conditions rather than preprocessor conditions.