-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
Description
aave-v4/src/libraries/math/MathUtils.sol
Lines 46 to 56 in 63caec0
| /** | |
| * @notice Adds a signed integer to an unsigned integer. | |
| * @dev Reverts on underflow. | |
| * @param a The unsigned integer. | |
| * @param b The signed integer. | |
| * @return The result of the addition. | |
| */ | |
| function add(uint256 a, int256 b) internal pure returns (uint256) { | |
| if (b >= 0) return a + uint256(b); | |
| return a - uint256(-b); | |
| } |
This can be optimised to be written branchless-ly. See min implementation above or oz for inspiration.