From 86328415fa5f13759a44673fa24ab0cf09db787c Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Jan 2011 17:17:42 +0000 Subject: [PATCH] Increase branch prediction on clamp function --- glm/core/func_common.inl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/glm/core/func_common.inl b/glm/core/func_common.inl index 4020c556..9ac12ef5 100644 --- a/glm/core/func_common.inl +++ b/glm/core/func_common.inl @@ -729,9 +729,11 @@ namespace glm detail::type::is_int || detail::type::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