From e1d26d5208912fc76a0dc7646ee17a41589f0316 Mon Sep 17 00:00:00 2001 From: joaonevess Date: Sun, 23 Jun 2024 23:57:17 -0300 Subject: [PATCH 1/2] optimize safeMul to reduce gas cost by 5 units --- src/math/SafeMath.huff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/math/SafeMath.huff b/src/math/SafeMath.huff index e735e84c..eb3c9658 100644 --- a/src/math/SafeMath.huff +++ b/src/math/SafeMath.huff @@ -46,7 +46,7 @@ dup1 // [num1, num1, num2] is_not_zero jumpi // [num1, num2] mul // [result] - 0x01 is_not_overflow jumpi + is_not_overflow jump is_not_zero: // [num1, num2] dup2 // [num2, num1, num2] dup2 // [num1, num2, num1, num2] From 0837b0c0c79ae61c5345391354779784306c4c63 Mon Sep 17 00:00:00 2001 From: joaonevess Date: Mon, 24 Jun 2024 04:57:39 -0300 Subject: [PATCH 2/2] Optimization (Trigonometry): removed redundant iszero iszero sequence --- src/math/Trigonometry.huff | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/math/Trigonometry.huff b/src/math/Trigonometry.huff index 3aecf40f..2ac9b964 100644 --- a/src/math/Trigonometry.huff +++ b/src/math/Trigonometry.huff @@ -94,8 +94,7 @@ dup4 // [angle, is_odd_quadrant, index, interp, angle] [QUADRANT_HIGH_MASK] // [QUADRANT_HIGH_MASK, angle, is_odd_quadrant, index, interp, angle] - and // [QUADRANT_HIGH_MASK & angle, is_odd_quadrant, index, interp, angle] - iszero iszero // [is_negative_quadrant, is_odd_quadrant, index, interp, angle] + and // [is_negative_quadrant, is_odd_quadrant, index, interp, angle] // Jump past updating the index if `is_odd_quadrant` is true dup2 is_odd_q jumpi // [is_negative_quadrant, is_odd_quadrant, index, interp, angle]