diff --git a/src/utils/csv_parsing.cpp b/src/utils/csv_parsing.cpp index 54a490e69..ff37b5bb8 100644 --- a/src/utils/csv_parsing.cpp +++ b/src/utils/csv_parsing.cpp @@ -203,7 +203,7 @@ Reader::ParsingResult Reader::ParseRow(utils::MemoryResource *mem) { // parse the header. // Also, if we don't have a header, the 'number_of_columns_' will be 0, so no // need to check the number of columns. - if (UNLIKELY(number_of_columns_ != 0 && row.size() != number_of_columns_)) { + if (number_of_columns_ != 0 && row.size() != number_of_columns_) [[unlikely]] { return ParseError(ParseError::ErrorCode::BAD_NUM_OF_COLUMNS, // ToDo(the-joksim): // - 'line_count_ - 1' is the last line of a row (as a diff --git a/src/utils/logging.hpp b/src/utils/logging.hpp index 888a3466a..f8f9875a1 100644 --- a/src/utils/logging.hpp +++ b/src/utils/logging.hpp @@ -26,10 +26,8 @@ #include <spdlog/sinks/stdout_color_sinks.h> #include <spdlog/spdlog.h> -#include "utils/likely.hpp" - namespace logging { -#ifndef NDEBUG + // TODO (antonio2368): Replace with std::source_location when it's supported by // compilers template <typename... Args> @@ -47,24 +45,12 @@ void AssertFailed(const char *file_name, int line_num, const char *expr, const A std::terminate(); } -// TODO (antonio2368): Replace with attribute [[likely]] when it's supported by -// compilers #define MG_ASSERT(expr, ...) \ - LIKELY(!!(expr)) \ - ? (void)0 : ::logging::AssertFailed(__FILE__, __LINE__, #expr, ##__VA_ARGS__) + [[likely]] !!(expr) ? (void)0 : ::logging::AssertFailed(__FILE__, __LINE__, #expr, ##__VA_ARGS__) + +#ifndef NDEBUG #define DMG_ASSERT(expr, ...) MG_ASSERT(expr, __VA_ARGS__) #else -template <typename... Args> -void AssertFailed(const Args &...msg_args) { - if constexpr (sizeof...(msg_args) > 0) { - spdlog::critical("Assertion failed with message: '{}'", fmt::format(msg_args...).c_str()); - } else { - spdlog::critical("Assertion failed"); - } - std::terminate(); -} - -#define MG_ASSERT(expr, ...) LIKELY(!!(expr)) ? (void)0 : ::logging::AssertFailed(__VA_ARGS__) #define DMG_ASSERT(...) #endif