diff options
author | 2021-08-15 21:29:39 -0400 | |
---|---|---|
committer | 2021-08-15 21:32:53 -0400 | |
commit | 0298e5d6c376f5df0cefe1b9a84840eba39f0ebc (patch) | |
tree | 719da5f05bade2379610254ce842e0896ed0bd71 /src/lib/util/timeconv.h | |
parent | 08a0e5af5be40da3b97302d85961f32ddee2bd54 (diff) |
Use std::clamp in more source files
Diffstat (limited to 'src/lib/util/timeconv.h')
-rw-r--r-- | src/lib/util/timeconv.h | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/lib/util/timeconv.h b/src/lib/util/timeconv.h index 2eb495a70aa..f9d1b070012 100644 --- a/src/lib/util/timeconv.h +++ b/src/lib/util/timeconv.h @@ -181,13 +181,10 @@ private: static int clamp_or_throw(int value, int minimum, int maximum, bool clamp, const char *out_of_range_message) { - if (value < minimum || value > maximum) - { - if (clamp) - value = std::min(std::max(value, minimum), maximum); - else - throw std::out_of_range(out_of_range_message); - } + if (clamp) + value = std::clamp(value, minimum, maximum); + else if (value < minimum || value > maximum) + throw std::out_of_range(out_of_range_message); return value; } |