The linked mathematical operation is guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.
Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statement to be wrapped in an unchecked code block thereby optimizing its execution cost.
MHR-02C: Ineffectual Usage of Safe Arithmetics
Description:
The linked mathematical operation is guaranteed to be performed safely by surrounding conditionals evaluated in either
require
checks orif-else
constructs.Example:
Recommendation:
Given that safe arithmetics are toggled on by default in
pragma
versions of0.8.X
, we advise the linked statement to be wrapped in anunchecked
code block thereby optimizing its execution cost.