From 3e64b2c1f955ef4ad6187e0a699c72826878258e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 24 Mar 2024 20:48:57 +0000 Subject: [PATCH] VectorLength reduces complexity. --- src/common/shared/shared.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/common/shared/shared.c b/src/common/shared/shared.c index 34aa155e..54fb139c 100644 --- a/src/common/shared/shared.c +++ b/src/common/shared/shared.c @@ -577,19 +577,9 @@ double sqrt(double x); vec_t VectorLength(vec3_t v) { - int i; - float length; - - length = 0; - - for (i = 0; i < 3; i++) - { - length += v[i] * v[i]; - } - - length = (float)sqrt(length); - - return length; + return sqrtf((v[0] * v[0]) + + (v[1] * v[1]) + + (v[2] * v[2])); } void