From 00dbbd5ce2f2b7c65e13589424263ba32cd068f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 29 Dec 2010 21:34:09 +0100 Subject: [PATCH] Optimization: using dot product for computing vector length. --- src/Math/Vector.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Math/Vector.h b/src/Math/Vector.h index e5af334d4..96ed4e9b4 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -159,12 +159,8 @@ template class Vector { } /** @brief Vector length */ - T length() const { - T out(0); - for(size_t i = 0; i != size; ++i) - out += pow(at(i), 2); - - return sqrt(out); + inline T length() const { + return sqrt(operator*(*this)); } /** @brief Normalized vector (of length 1) */