Increase branch prediction on clamp function

This commit is contained in:
Christophe Riccio 2011-01-31 17:17:42 +00:00
parent 8387847c42
commit 86328415fa

View File

@ -729,9 +729,11 @@ namespace glm
detail::type<valType>::is_int ||
detail::type<valType>::is_uint, "'clamp' only accept numbers");
if(x >= maxVal) return maxVal;
if(x <= minVal) return minVal;
return x;
// Old implementation, less predictable branching
//if(x >= maxVal) return maxVal;
//if(x <= minVal) return minVal;
//return x;
return glm::max(glm::min(x, maxVal), minVal);
}
template <typename T>