Commit a87121f9 by Olli Etuaho Committed by Commit Bot

Fix build warning by specializing clampCast

Casting integers to booleans generates a performance warning in at least MSVS 2015 x64 Debug build. Specialize the clampCast template for bool->int conversion to avoid this warning, which is treated as an error. BUG=angleproject:2165 TEST=MSVS 2015 x64 Debug build Change-Id: Iaa9591c102cdd73fe9ff8a8739d356cc13cec248 Reviewed-on: https://chromium-review.googlesource.com/704820 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent e159717d
...@@ -94,6 +94,20 @@ inline DestT clampCast(SrcT value) ...@@ -94,6 +94,20 @@ inline DestT clampCast(SrcT value)
return static_cast<DestT>(value); return static_cast<DestT>(value);
} }
// Specialize clampCast for bool->int conversion to avoid MSVS 2015 performance warning when the max
// value is casted to the source type.
template <>
inline unsigned int clampCast(bool value)
{
return static_cast<unsigned int>(value);
}
template <>
inline int clampCast(bool value)
{
return static_cast<int>(value);
}
template<typename T, typename MIN, typename MAX> template<typename T, typename MIN, typename MAX>
inline T clamp(T x, MIN min, MAX max) inline T clamp(T x, MIN min, MAX max)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment