mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-20 15:03:25 +00:00
common: optimize clamp() for reduced overhead in web
This commit is contained in:
parent
f5aa347a70
commit
5361ad1617
1 changed files with 3 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
|
Loading…
Add table
Reference in a new issue