From 75c8e0af7ca1d633aa3c6f3871b81d5f47371ef9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Oct 2021 10:21:50 +0200 Subject: [PATCH] - use the standard library's 'clamp' function instead of our homegrown variant. --- src/common/engine/renderstyle.cpp | 2 +- src/common/textures/hw_ihwtexture.cpp | 4 ++-- src/common/utility/basics.h | 1 + src/common/utility/templates.h | 13 ------------- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/common/engine/renderstyle.cpp b/src/common/engine/renderstyle.cpp index 1a29292ea..e31538b4f 100644 --- a/src/common/engine/renderstyle.cpp +++ b/src/common/engine/renderstyle.cpp @@ -32,7 +32,7 @@ ** */ -#include "templates.h" +#include "basics.h" #include "renderstyle.h" #include "c_cvars.h" diff --git a/src/common/textures/hw_ihwtexture.cpp b/src/common/textures/hw_ihwtexture.cpp index aebf387d4..f86daa5c1 100644 --- a/src/common/textures/hw_ihwtexture.cpp +++ b/src/common/textures/hw_ihwtexture.cpp @@ -34,7 +34,7 @@ */ #include "hw_ihwtexture.h" -#include "templates.h" +#include "basics.h" #include "tarray.h" #include "xs_Float.h" @@ -68,7 +68,7 @@ static void ResampleBoxPrecalc(TArray& boxes, int oldDim) BoxPrecalc& precalc = boxes[dst]; precalc.boxStart = clamp(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1); - precalc.boxEnd = clamp(MAX(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1); + precalc.boxEnd = clamp(max(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1); } } diff --git a/src/common/utility/basics.h b/src/common/utility/basics.h index 703a84c30..29ee19593 100644 --- a/src/common/utility/basics.h +++ b/src/common/utility/basics.h @@ -105,3 +105,4 @@ enum EStateUseFlags using std::min; using std::max; +using std::clamp; diff --git a/src/common/utility/templates.h b/src/common/utility/templates.h index 3f3e596f0..7babf3f99 100644 --- a/src/common/utility/templates.h +++ b/src/common/utility/templates.h @@ -129,18 +129,5 @@ const T MAX (const T a, const T b) return a > b ? a : b; } -//========================================================================== -// -// clamp -// -// Clamps in to the range [min,max]. -//========================================================================== - -template -inline constexpr -T clamp (const T in, const X min, const Y max) -{ - return in <= (T) min ? (T) min : in >= (T) max ? (T) max : in; -} #endif //__TEMPLATES_H__