From d32039ef96cce6d2a5560a6a8ec805cf7c4bc4ae Mon Sep 17 00:00:00 2001 From: keosariel Date: Fri, 29 Jul 2022 07:37:26 +0100 Subject: [PATCH] fix: :zap: modulus operator optimization --- src/math.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/math.sol b/src/math.sol index 5ea5761..03ffc38 100644 --- a/src/math.sol +++ b/src/math.sol @@ -75,12 +75,12 @@ contract DSMath { // floor[(n-1) / 2] = floor[n / 2]. // function rpow(uint x, uint n) internal pure returns (uint z) { - z = n % 2 != 0 ? x : RAY; + z = n & 1 != 0 ? x : RAY; for (n /= 2; n != 0; n /= 2) { x = rmul(x, x); - if (n % 2 != 0) { + if (n & 1 != 0) { z = rmul(z, x); } }