diff --git a/include/macros.h b/include/macros.h index fd44f4b..9246d0b 100644 --- a/include/macros.h +++ b/include/macros.h @@ -88,6 +88,11 @@ __attribute__((hot)); \ expr; \ }) +// Use like: COLD_BLOCK { ... } +// XXX: I'm not exactly sure if these hacks work.. Should test. +#define COLD_BLOCK if(UNLIKELY(1)) +// Use like: HOT_BLOCK { ... } +#define HOT_BLOCK if(LIKELY(1)) /// Equivalent to GNU C `x ?: y` operator. #define TERN_OR(x, y) ({ let _x = (x); _x ? _x : (y); }) diff --git a/include/map.h b/include/map.h index 19fb4a5..770ea8a 100644 --- a/include/map.h +++ b/include/map.h @@ -53,7 +53,7 @@ const char* map_error_str(map_result_t res); _mixin int _map_handle_err(const char* stmt, const char* file, int line, const char* func, map_result_t res) { if(res == MAP_SUCCESS) return 1; - else { + else COLD_BLOCK { const char* err = map_error_str(res); ERROR("mapping failed at %s:%d->%s(): on stmt `%s`", file, line, func, stmt); switch(res) {