Skip to content

Commit 970285a

Browse files
committed
Code cleanup
1 parent 857a285 commit 970285a

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

math/math.hpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ template <typename ResultType, typename... Args>
156156
return ((uint64_t)value * (uint64_t)range) >> 32;
157157
}
158158

159+
namespace detail {
160+
159161
inline uint32_t fastmod_u32(uint32_t a, uint64_t M, uint32_t d) noexcept
160162
{
161163
const uint64_t lowbits = M * a;
@@ -173,19 +175,22 @@ inline uint32_t fastmod_u32(uint32_t a, uint64_t M, uint32_t d) noexcept
173175
inline constexpr uint64_t computeM_u32(uint32_t d) noexcept {
174176
return UINT64_C(0xFFFFFFFFFFFFFFFF) / d + 1;
175177
}
178+
} // namespace detail
176179

177-
class FastMod32
180+
struct FastMod32
178181
{
179-
const uint64_t M;
180-
const uint32_t d;
181-
public:
182182
inline constexpr FastMod32(uint32_t divisor) noexcept
183-
: M(computeM_u32(divisor)), d(divisor)
183+
: M(detail::computeM_u32(divisor)), d(divisor)
184184
{}
185-
inline uint32_t mod(uint32_t a) const noexcept
185+
186+
[[nodiscard]] inline uint32_t mod(uint32_t a) const noexcept
186187
{
187-
return fastmod_u32(a, M, d);
188+
return detail::fastmod_u32(a, M, d);
188189
}
190+
191+
private:
192+
const uint64_t M;
193+
const uint32_t d;
189194
};
190195

191196
} // namespace Math

0 commit comments

Comments
 (0)