From 41aaf1321f898ce60e7db2aabbb5e7a5dd228c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 16 Dec 2016 09:23:13 +0100 Subject: [PATCH] Math: construct fully-overwritten outputs in functions with NoInit. Slightly faster on non-optimized builds (I would assume the optimizer does this anyway). --- src/Magnum/Math/Functions.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Magnum/Math/Functions.h b/src/Magnum/Math/Functions.h index 333313892..284f09f72 100644 --- a/src/Magnum/Math/Functions.h +++ b/src/Magnum/Math/Functions.h @@ -208,7 +208,7 @@ template inline typename std::enable_if::value, T return std::min(value, min); } template inline Vector min(const Vector& value, const Vector& min) { - Vector out; + Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) out[i] = std::min(value[i], min[i]); return out; @@ -236,7 +236,7 @@ template inline typename std::enable_if::value, T return std::max(value, max); } template Vector max(const Vector& value, const Vector& max) { - Vector out; + Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) out[i] = std::max(value[i], max[i]); return out; @@ -289,7 +289,7 @@ template inline typename std::enable_if::value, T return std::min(std::max(value, min), max); } template Vector clamp(const Vector& value, T min, T max) { - Vector out; + Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) out[i] = clamp(value[i], min, max); return out; @@ -310,7 +310,7 @@ template inline typename std::enable_if::value, T return T(0); } template Vector sign(const Vector& a) { - Vector out; + Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) out[i] = sign(a[i]); return out; @@ -325,7 +325,7 @@ template inline typename std::enable_if::value, T return std::abs(a); } template Vector abs(const Vector& a) { - Vector out; + Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) out[i] = std::abs(a[i]); return out; @@ -340,7 +340,7 @@ template inline typename std::enable_if::value, T return std::floor(a); } template Vector floor(const Vector& a) { - Vector out; + Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) out[i] = std::floor(a[i]); return out; @@ -360,7 +360,7 @@ template inline typename std::enable_if::value, T #endif } template Vector round(const Vector& a) { - Vector out; + Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) { #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) out[i] = std::round(a[i]); @@ -380,7 +380,7 @@ template inline typename std::enable_if::value, T return std::ceil(a); } template Vector ceil(const Vector& a) { - Vector out; + Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) out[i] = std::ceil(a[i]); return out; @@ -399,7 +399,7 @@ template inline typename std::enable_if::value, T return T(std::sqrt(a)); } template Vector sqrt(const Vector& a) { - Vector out; + Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) out[i] = T(std::sqrt(a[i])); return out; @@ -459,7 +459,7 @@ template inline Vector lerp(const Vector inline BoolVector lerp(const BoolVector& a, const BoolVector& b, const BoolVector& t) { - BoolVector out; + BoolVector out{NoInit}; for(std::size_t i = 0; i != size; ++i) out.set(i, t[i] ? b[i] : a[i]); return out;