Closed DevUreak closed 1 week ago
Thank you @DevUreak ,
This code belongs to the Optimism team. We did not change anything here. And do you know how much gas can we save if using ternary operator?
The gas cost per ternary operator conversion is quite low, around 50, so the difference isn't significant even if we don't make the change. I've thought about what we can gain with minimal changes and effort :)
I think it is great! Lets use ternary operator. Thank you!
Thanks @DevUreak. I agree. Your suggestion is that it improves readability and conciseness also saving some gas.
Confirmed. e67168dbdbc5df0082fa908b609b46cb3dfb9fc9
Describe the bug
How about applying the ternary operator to some parts of the code?
There are instances where we use the ternary operator in the project. Using the ternary operator can reduce gas consumption, and in some cases, it can also improve readability.
Configuration
Severity: low Impact
Recommendation ex. OptimismPortal.sol
base
address from = _sender;
if (_sender != tx.origin) {
from = AddressAliasHelper.applyL1ToL2Alias(_sender);
}
after
address from = _sender != tx.origin ? AddressAliasHelper.applyL1ToL2Alias(_sender) : _sender
Exploit Scenario
Demo