diff options
author | nat-goodspeed <nat@lindenlab.com> | 2023-03-03 17:34:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 17:34:03 -0500 |
commit | f2a784f0d07ac8bedb4e84f8ce60bfbe513d7dfb (patch) | |
tree | 9789b0035169b494e360d47ec2449a7614cd36c8 /indra/llcommon/lldefs.h | |
parent | d9ef67187532f528a0a8072da55ac0237ec3e4ff (diff) | |
parent | 42b1fd21814e679a1557e0d5a55943c5b0e63723 (diff) |
Merge pull request #99 from secondlife/sl-18330-fixes
SL-18330: Address further code review comments
Diffstat (limited to 'indra/llcommon/lldefs.h')
-rw-r--r-- | indra/llcommon/lldefs.h | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h index 5c46f6a796..4e25001fff 100644 --- a/indra/llcommon/lldefs.h +++ b/indra/llcommon/lldefs.h @@ -167,48 +167,34 @@ const U32 MAXADDRSTR = 17; // 123.567.901.345 = 15 chars + \0 + 1 for good luc // // defined for U16, U32, U64, S16, S32, S64, : // llclampb(a) // clamps a to [0 .. 255] -// - -template <typename T1, typename T2> -inline auto llmax(T1 d1, T2 d2) -{ - return (d1 > d2) ? d1 : d2; -} - -template <typename T1, typename T2, typename T3> -inline auto llmax(T1 d1, T2 d2, T3 d3) -{ - auto r = llmax(d1,d2); - return llmax(r, d3); -} +// -template <typename T1, typename T2, typename T3, typename T4> -inline auto llmax(T1 d1, T2 d2, T3 d3, T4 d4) +// recursion tail +template <typename T> +inline auto llmax(T data) { - auto r1 = llmax(d1,d2); - auto r2 = llmax(d3,d4); - return llmax(r1, r2); + return data; } -template <typename T1, typename T2> -inline auto llmin(T1 d1, T2 d2) +template <typename T0, typename T1, typename... Ts> +inline auto llmax(T0 d0, T1 d1, Ts... rest) { - return (d1 < d2) ? d1 : d2; + auto maxrest = llmax(d1, rest...); + return (d0 > maxrest)? d0 : maxrest; } -template <typename T1, typename T2, typename T3> -inline auto llmin(T1 d1, T2 d2, T3 d3) +// recursion tail +template <typename T> +inline auto llmin(T data) { - auto r = llmin(d1,d2); - return (r < d3 ? r : d3); + return data; } -template <typename T1, typename T2, typename T3, typename T4> -inline auto llmin(T1 d1, T2 d2, T3 d3, T4 d4) +template <typename T0, typename T1, typename... Ts> +inline auto llmin(T0 d0, T1 d1, Ts... rest) { - auto r1 = llmin(d1,d2); - auto r2 = llmin(d3,d4); - return llmin(r1, r2); + auto minrest = llmin(d1, rest...); + return (d0 < minrest) ? d0 : minrest; } template <typename A, typename MIN, typename MAX> |