From 2c0b29143ad84b57df021d227b541aa2ab6a52f9 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 5 Mar 2025 08:41:22 -0600 Subject: [PATCH] refactor: remove `TR_LIKELY` and `TR_UNLIKELY` macros (#7469) * refactor: remove unused TR_UNLIKELY macro * refactor: remove TR_LIKELY from assertion macro https://blog.aaronballman.com/2020/08/dont-use-the-likely-or-unlikely-attributes/ * refactor: remove unuse TR_LIKELY macro * refactor: remove unused TR_GNUC_CHECK_VERSION macro * refactor: remove unused __has_builtin fallback macro --- libtransmission/tr-assert.h | 4 ++-- libtransmission/tr-macros.h | 20 -------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/libtransmission/tr-assert.h b/libtransmission/tr-assert.h index 845c8d12e..b069edd8e 100644 --- a/libtransmission/tr-assert.h +++ b/libtransmission/tr-assert.h @@ -13,8 +13,8 @@ [[noreturn]] bool tr_assert_report(std::string_view file, long line, std::string_view message); -#define TR_ASSERT(x) ((void)(TR_LIKELY(x) || tr_assert_report(__FILE__, __LINE__, #x))) -#define TR_ASSERT_MSG(x, message) ((void)(TR_LIKELY(x) || tr_assert_report(__FILE__, __LINE__, message))) +#define TR_ASSERT(x) ((void)((x) || tr_assert_report(__FILE__, __LINE__, #x))) +#define TR_ASSERT_MSG(x, message) ((void)((x) || tr_assert_report(__FILE__, __LINE__, message))) #define TR_UNREACHABLE() tr_assert_report(__FILE__, __LINE__, "Unreachable code") #define TR_ENABLE_ASSERTS diff --git a/libtransmission/tr-macros.h b/libtransmission/tr-macros.h index d08845604..3a11cd3a6 100644 --- a/libtransmission/tr-macros.h +++ b/libtransmission/tr-macros.h @@ -30,22 +30,12 @@ // --- -#ifndef __has_builtin -#define __has_builtin(x) 0 -#endif - #ifdef _WIN32 #define TR_IF_WIN32(ThenValue, ElseValue) ThenValue #else #define TR_IF_WIN32(ThenValue, ElseValue) ElseValue #endif -#ifdef __GNUC__ -#define TR_GNUC_CHECK_VERSION(major, minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) -#else -#define TR_GNUC_CHECK_VERSION(major, minor) 0 -#endif - #ifdef __UCLIBC__ #define TR_UCLIBC_CHECK_VERSION(major, minor, micro) \ (__UCLIBC_MAJOR__ > (major) || (__UCLIBC_MAJOR__ == (major) && __UCLIBC_MINOR__ > (minor)) || \ @@ -56,16 +46,6 @@ // --- -#if __has_builtin(__builtin_expect) || TR_GNUC_CHECK_VERSION(3, 0) -#define TR_LIKELY(x) __builtin_expect((x) ? 1L : 0L, 1L) -#define TR_UNLIKELY(x) __builtin_expect((x) ? 1L : 0L, 0L) -#else -#define TR_LIKELY(x) (x) -#define TR_UNLIKELY(x) (x) -#endif - -// --- - #define TR_INET6_ADDRSTRLEN 46 #define TR_ADDRSTRLEN 64