common: optimize clamp() for reduced overhead in web

This commit is contained in:
Jinny You 2025-01-13 20:13:56 +08:00 committed by Hermet Park
parent f5aa347a70
commit 5361ad1617

View file

@ -71,7 +71,9 @@ static inline bool equal(float a, float b)
template <typename T>
static inline constexpr const T& clamp(const T& v, const T& min, const T& max)
{
return std::min(std::max(v, min), max);
if (v < min) return min;
else if (v > max) return max;
return v;
}
/************************************************************************/