From cc9a787f146d89723312ad13097a4353519450ae Mon Sep 17 00:00:00 2001 From: joaquintides Date: Tue, 26 Aug 2025 17:08:01 +0200 Subject: [PATCH] microoptimized unchecked_countr_zero for GCC/Clang --- include/boost/unordered/detail/foa/core.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/unordered/detail/foa/core.hpp b/include/boost/unordered/detail/foa/core.hpp index fab35866..38d50e68 100644 --- a/include/boost/unordered/detail/foa/core.hpp +++ b/include/boost/unordered/detail/foa/core.hpp @@ -923,6 +923,8 @@ inline unsigned int unchecked_countr_zero(int x) unsigned long r; _BitScanForward(&r,(unsigned long)x); return (unsigned int)r; +#elif defined(BOOST_GCC)||defined(BOOST_CLANG) + return (unsigned int)__builtin_ctz((unsigned int)x); #else BOOST_UNORDERED_ASSUME(x!=0); return (unsigned int)boost::core::countr_zero((unsigned int)x);