Functions can be defined outside of a contract, also called “free functions”, always have implicit internal visibility.
Every call to an external contract costs a decent amount of gas. For optimization of gas usage, use free functions to replace external calls can save gas.
For example:
Basket.sol#validateWeights() can be defined as a free function, so that Factory.sol#proposeBasketLicense() can save an external call.
Handle
WatchPug
Vulnerability details
Functions can be defined outside of a contract, also called “free functions”, always have implicit internal visibility.
Every call to an external contract costs a decent amount of gas. For optimization of gas usage, use free functions to replace external calls can save gas.
For example:
Basket.sol#validateWeights()
can be defined as a free function, so thatFactory.sol#proposeBasketLicense()
can save an external call.https://github.com/code-423n4/2021-12-defiprotocol/blob/205d3766044171e325df6a8bf2e79b37856eece1/contracts/contracts/Factory.sol#L75-L75