From d844317a6dbb3034075aa2923ee9430625b97dc0 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Thu, 29 Jun 2023 01:32:51 -0500 Subject: [PATCH] Common: Better AlignUp implementation --- Source/Core/Common/Align.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/Core/Common/Align.h b/Source/Core/Common/Align.h index 8e51b8aacc..994e505617 100644 --- a/Source/Core/Common/Align.h +++ b/Source/Core/Common/Align.h @@ -7,12 +7,6 @@ namespace Common { -template -constexpr T AlignUp(T value, size_t size) -{ - static_assert(std::is_unsigned(), "T must be an unsigned value."); - return static_cast(value + (size - value % size) % size); -} template constexpr T AlignDown(T value, size_t size) @@ -21,4 +15,11 @@ constexpr T AlignDown(T value, size_t size) return static_cast(value - value % size); } +template +constexpr T AlignUp(T value, size_t size) +{ + static_assert(std::is_unsigned(), "T must be an unsigned value."); + return AlignDown(static_cast(value + (size - 1)), size); +} + } // namespace Common