зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1821362 - Add a generic CountTrailingZeroes function that lowers to the right intrinsic based the type its called with. r=sergesanspaille
Differential Revision: https://phabricator.services.mozilla.com/D173314
This commit is contained in:
Родитель
256aab271f
Коммит
63452a9038
|
@ -453,6 +453,19 @@ inline T Clamp(const T aValue, const T aMin, const T aMax) {
|
|||
return aValue;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline uint_fast8_t CountTrailingZeroes(T aValue) {
|
||||
static_assert(sizeof(T) <= 8);
|
||||
static_assert(std::is_integral_v<T>);
|
||||
// This casts to 32-bits
|
||||
if constexpr (sizeof(T) <= 4) {
|
||||
return CountTrailingZeroes32(aValue);
|
||||
}
|
||||
// This doesn't
|
||||
if constexpr (sizeof(T) == 8) {
|
||||
return CountTrailingZeroes64(aValue);
|
||||
}
|
||||
}
|
||||
} /* namespace mozilla */
|
||||
|
||||
#endif /* mozilla_MathAlgorithms_h */
|
||||
|
|
Загрузка…
Ссылка в новой задаче