From ea4b0babcdd84b1106fe26ec06c66bc03ce4b38c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 7 Mar 2020 23:59:45 +0100 Subject: [PATCH] Wrap the debug print functions in unlikely macros Since the compiler can't tell that these routines should never be hit during normal usage. --- src/common/logging.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/logging.cpp b/src/common/logging.cpp index 166d24c9..2c69f034 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -85,7 +85,7 @@ void Logger::log(const std::string& message) { } void Logger::log_get_parameter(int32_t index) { - if (verbosity >= Verbosity::events) { + if (BOOST_UNLIKELY(verbosity >= Verbosity::events)) { std::ostringstream message; message << ">> getParameter() " << index; @@ -94,7 +94,7 @@ void Logger::log_get_parameter(int32_t index) { } void Logger::log_get_parameter_response(float value) { - if (verbosity >= Verbosity::events) { + if (BOOST_UNLIKELY(verbosity >= Verbosity::events)) { std::ostringstream message; message << " getParameter() :: " << value; @@ -103,7 +103,7 @@ void Logger::log_get_parameter_response(float value) { } void Logger::log_set_parameter(int32_t index, float value) { - if (verbosity >= Verbosity::events) { + if (BOOST_UNLIKELY(verbosity >= Verbosity::events)) { std::ostringstream message; message << ">> setParameter() " << index << " = " << value; @@ -112,7 +112,7 @@ void Logger::log_set_parameter(int32_t index, float value) { } void Logger::log_set_parameter_response() { - if (verbosity >= Verbosity::events) { + if (BOOST_UNLIKELY(verbosity >= Verbosity::events)) { log(" setParameter() :: OK"); } } @@ -123,7 +123,7 @@ void Logger::log_event(bool is_dispatch, intptr_t value, std::optional payload, float option) { - if (verbosity >= Verbosity::events) { + if (BOOST_UNLIKELY(verbosity >= Verbosity::events)) { std::ostringstream message; if (is_dispatch) { message << ">> dispatch() "; @@ -157,7 +157,7 @@ void Logger::log_event(bool is_dispatch, void Logger::log_event_response(bool is_dispatch, intptr_t return_value, std::optional payload) { - if (verbosity >= Verbosity::events) { + if (BOOST_UNLIKELY(verbosity >= Verbosity::events)) { std::ostringstream message; if (is_dispatch) { message << " dispatch() :: ";