summaryrefslogtreecommitdiffstats
path: root/src/common/alignment.h
diff options
context:
space:
mode:
authorMarshall Mohror <mohror64@gmail.com>2020-07-07 23:39:23 +0200
committerFearlessTobi <thm.frey@gmail.com>2020-07-11 18:39:00 +0200
commita4306b9e5662fca74f65f0b657e7002fda7f1829 (patch)
treecbd176cf7b3dd85cde0b8fb65f8df38727d1c9a5 /src/common/alignment.h
parentMerge pull request #4203 from VolcaEM/services (diff)
downloadyuzu-a4306b9e5662fca74f65f0b657e7002fda7f1829.tar
yuzu-a4306b9e5662fca74f65f0b657e7002fda7f1829.tar.gz
yuzu-a4306b9e5662fca74f65f0b657e7002fda7f1829.tar.bz2
yuzu-a4306b9e5662fca74f65f0b657e7002fda7f1829.tar.lz
yuzu-a4306b9e5662fca74f65f0b657e7002fda7f1829.tar.xz
yuzu-a4306b9e5662fca74f65f0b657e7002fda7f1829.tar.zst
yuzu-a4306b9e5662fca74f65f0b657e7002fda7f1829.zip
Diffstat (limited to '')
-rw-r--r--src/common/alignment.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h
index f8c49e079..516bb26c1 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -11,7 +11,9 @@ namespace Common {
template <typename T>
constexpr T AlignUp(T value, std::size_t size) {
static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
- return static_cast<T>(value + (size - value % size) % size);
+ auto mod{value % size};
+ value -= mod;
+ return static_cast<T>(mod == T{0} ? value : value + size);
}
template <typename T>