summaryrefslogtreecommitdiffstats
path: root/src/common/settings.h
diff options
context:
space:
mode:
authorlat9nq <22451773+lat9nq@users.noreply.github.com>2021-07-31 23:20:12 +0200
committerlat9nq <22451773+lat9nq@users.noreply.github.com>2021-07-31 23:20:12 +0200
commit3862511a9ad294918682dccf7765f43df166e0d7 (patch)
tree543f75c5c58486cec530ef9807ff722caf224bd7 /src/common/settings.h
parentsettings: Remove unnecessary std::move usages (diff)
downloadyuzu-3862511a9ad294918682dccf7765f43df166e0d7.tar
yuzu-3862511a9ad294918682dccf7765f43df166e0d7.tar.gz
yuzu-3862511a9ad294918682dccf7765f43df166e0d7.tar.bz2
yuzu-3862511a9ad294918682dccf7765f43df166e0d7.tar.lz
yuzu-3862511a9ad294918682dccf7765f43df166e0d7.tar.xz
yuzu-3862511a9ad294918682dccf7765f43df166e0d7.tar.zst
yuzu-3862511a9ad294918682dccf7765f43df166e0d7.zip
Diffstat (limited to '')
-rw-r--r--src/common/settings.h48
1 files changed, 9 insertions, 39 deletions
diff --git a/src/common/settings.h b/src/common/settings.h
index 4432b5ddd..69f4adaeb 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -4,6 +4,7 @@
#pragma once
+#include <algorithm>
#include <array>
#include <atomic>
#include <chrono>
@@ -168,15 +169,7 @@ public:
* @param value The desired value
*/
void SetValue(const Type& value) override {
- Type temp;
- if (value < minimum) {
- temp = minimum;
- } else if (value > maximum) {
- temp = maximum;
- } else {
- temp = value;
- }
- std::swap(this->global, temp);
+ this->global = std::clamp(value, minimum, maximum);
}
/**
@@ -186,15 +179,7 @@ public:
* @returns A reference to the setting's value
*/
const Type& operator=(const Type& value) override {
- Type temp;
- if (value < minimum) {
- temp = minimum;
- } else if (value > maximum) {
- temp = maximum;
- } else {
- temp = value;
- }
- std::swap(this->global, temp);
+ this->global = std::clamp(value, minimum, maximum);
return this->global;
}
@@ -342,19 +327,11 @@ public:
* @param value The desired value
*/
void SetValue(const Type& value) override {
- Type temp;
- if (value < this->minimum) {
- temp = this->minimum;
- } else if (value > this->maximum) {
- temp = this->maximum;
- } else {
- temp = value;
- }
+ const Type temp = std::clamp(value, this->minimum, this->maximum);
if (this->use_global) {
- std::swap(this->global, temp);
- } else {
- std::swap(this->custom, temp);
+ this->global = temp;
}
+ this->custom = temp;
}
/**
@@ -365,19 +342,12 @@ public:
* @returns A reference to the setting's value
*/
const Type& operator=(const Type& value) override {
- Type temp;
- if (value < this->minimum) {
- temp = this->minimum;
- } else if (value > this->maximum) {
- temp = this->maximum;
- } else {
- temp = value;
- }
+ const Type temp = std::clamp(value, this->minimum, this->maximum);
if (this->use_global) {
- std::swap(this->global, temp);
+ this->global = temp;
return this->global;
}
- std::swap(this->custom, temp);
+ this->custom = temp;
return this->custom;
}
};