From 69b94a6eabdb5340e3ea0d2211fd588fce7fd761 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 28 Apr 2022 16:27:56 -0700 Subject: libs/din: minor optimization in clamp() short-circuit by directly returning bound when exceeded --- src/libs/din/din.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libs/din') diff --git a/src/libs/din/din.c b/src/libs/din/din.c index 44c6ec8..22e2848 100644 --- a/src/libs/din/din.c +++ b/src/libs/din/din.c @@ -92,10 +92,10 @@ static inline float lerp(float a, float b, float t) static inline float clamp(float x, float lowerlimit, float upperlimit) { if (x < lowerlimit) - x = lowerlimit; + return lowerlimit; if (x > upperlimit) - x = upperlimit; + return upperlimit; return x; } -- cgit v1.2.1