From 1198a052999747df9d007e01d99c3a02d5894b3d Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Sun, 21 Aug 2022 05:52:39 -0700 Subject: [PATCH] assert: identify the hot path Does result in code that branches a little differently. --- src/common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common.h b/src/common.h index c3efa26a1..9a7b954a4 100644 --- a/src/common.h +++ b/src/common.h @@ -214,8 +214,8 @@ extern const wcstring g_empty_string; /// stdio functions and should be writing the message to stderr rather than stdout. Second, if /// possible it is useful to provide additional context such as a stack backtrace. #undef assert -#define assert(e) (e) ? ((void)0) : __fish_assert(#e, __FILE__, __LINE__, 0) -#define assert_with_errno(e) (e) ? ((void)0) : __fish_assert(#e, __FILE__, __LINE__, errno) +#define assert(e) likely(e) ? ((void)0) : __fish_assert(#e, __FILE__, __LINE__, 0) +#define assert_with_errno(e) likely(e) ? ((void)0) : __fish_assert(#e, __FILE__, __LINE__, errno) #define DIE(msg) __fish_assert(msg, __FILE__, __LINE__, 0) #define DIE_WITH_ERRNO(msg) __fish_assert(msg, __FILE__, __LINE__, errno) /// This macro is meant to be used with functions that return zero on success otherwise return an