You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary
Suggest adjustments to comparison binary expressions to leverage short-circuit functionality.
Context
TVM supports short-circuit operations. For example, in the code: if (long_running_fun() && self.boolean_always_false), it would be more optimal to write it as: if (self.boolean_always_false && long_running_fun()). This pattern is present in several real-world contracts, making this detector useful for optimizing their code.
Short-circuit in TVM
For this function:
get fun test(a: Int): Int {
if ((a > 4) && (a > 5) && (a > 6)) {
return 44;
}
return 43;
}
Tact generates FunC code, which results in the following fift code, without providing any optimizations:
Summary
Suggest adjustments to comparison binary expressions to leverage short-circuit functionality.
Context
TVM supports short-circuit operations. For example, in the code:
if (long_running_fun() && self.boolean_always_false)
, it would be more optimal to write it as:if (self.boolean_always_false && long_running_fun())
. This pattern is present in several real-world contracts, making this detector useful for optimizing their code.Short-circuit in TVM
For this function:
Tact generates FunC code, which results in the following fift code, without providing any optimizations:
The underlying execution of the
IF
opcodes works this way: it pops the stack value and executes the continuation only if it istrue
.Therefore, TVM supports short-circuit operations, and the idea behind this detector is valid.
The text was updated successfully, but these errors were encountered: