From fa7153ecfbd18705f5cfbbdc316d693b943559e4 Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Sat, 21 Mar 2020 15:22:11 +0100 Subject: [PATCH] Matrix: omit min max nan case with same result I observed this during review in https://github.com/PX4/Matrix/pull/105/files#r348386226 --- matrix/Matrix.hpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/matrix/Matrix.hpp b/matrix/Matrix.hpp index 93077a8182..4229bbb7eb 100644 --- a/matrix/Matrix.hpp +++ b/matrix/Matrix.hpp @@ -620,9 +620,7 @@ Type min(const Type x, const Type y) { if (x_is_nan && !y_is_nan) { return y; } - if (!x_is_nan && y_is_nan) { - return x; - } + // either !x_is_nan && y_is_nan or both are NAN anyways return x; } return (x < y) ? x : y; @@ -636,9 +634,7 @@ Type max(const Type x, const Type y) { if (x_is_nan && !y_is_nan) { return y; } - if (!x_is_nan && y_is_nan) { - return x; - } + // either !x_is_nan && y_is_nan or both are NAN anyways return x; } return (x > y) ? x : y;